Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/312.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何更改prefs活动的背景?_Java_Android_Android Preferences - Fatal编程技术网

Java 如何更改prefs活动的背景?

Java 如何更改prefs活动的背景?,java,android,android-preferences,Java,Android,Android Preferences,我有一个prefs xml活动,其中有一个用于打开和关闭声音的复选框,还有一个用于用户键入其姓名的编辑框。是否有办法使prefs活动全屏显示并设置背景?如果可能的话,我想设置我自己的png背景。谢谢。使用主题并在中设置android:Theme=“@style/CustomTheme” <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.andr

我有一个prefs xml活动,其中有一个用于打开和关闭声音的复选框,还有一个用于用户键入其姓名的编辑框。是否有办法使prefs活动全屏显示并设置背景?如果可能的话,我想设置我自己的png背景。谢谢。

使用主题并在
中设置
android:Theme=“@style/CustomTheme”
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/backgroundimage"
android:gravity="center_horizontal"
android:orientation="vertical" >
使用以下项目在styles.xml中创建一个
CustomTheme

<style name="CustomTheme">
<item name="android:windowBackground">@drawable/backgroundimage</item>
<item name="android:windowFullscreen">true</item>
</style>

@可绘制/背景图像
真的

使用主题并在
中设置
android:Theme=“@style/CustomTheme”
使用以下项目在styles.xml中创建一个
CustomTheme

<style name="CustomTheme">
<item name="android:windowBackground">@drawable/backgroundimage</item>
<item name="android:windowFullscreen">true</item>
</style>

@可绘制/背景图像
真的
我的pref.xml文件:

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >

<EditTextPreference
    android:title="Ime"
    android:key="ime"
    android:summary="Upišite svoje ime">
</EditTextPreference>

<CheckBoxPreference
    android:title="Zvuk"
    android:defaultValue="true"
    android:key="checkbox"
    android:summary="Ukljucite ili iskljucite zvukove u igri"/>

</PreferenceScreen>

我的pref.xml文件:

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >

<EditTextPreference
    android:title="Ime"
    android:key="ime"
    android:summary="Upišite svoje ime">
</EditTextPreference>

<CheckBoxPreference
    android:title="Zvuk"
    android:defaultValue="true"
    android:key="checkbox"
    android:summary="Ukljucite ili iskljucite zvukove u igri"/>

</PreferenceScreen>


请确认此答案是否适用于您。谢谢。请确认这个答案是否对你有效。谢谢。不,我不能在首选项xml中使用线性布局。不,我不能在首选项xml中使用线性布局。以某种奇怪的方式工作。我确实得到了我的背景,但它的纵向拉伸是我屏幕大小的3到4倍。我的复选框在下面的某个地方丢失了。:)你能发布你的布局xml文件吗?如果我读对了,你正在使用的图像会被拉伸并在屏幕上显示多次。复选框仍然存在,但不清晰可见?如果是这种情况,您必须为不同的屏幕大小创建多个图像,并将它们放在不同的可绘制文件夹中。您可能需要根据正在使用的屏幕大小在res文件夹中创建新的drawablw文件夹,例如,可绘制的小屏幕、可绘制的普通屏幕等。请参阅链接查看我编辑的回复。尝试使用
android:windowBackground
而不是
android:background
我在游戏的其余部分都有相同的背景图像,它在每一个活动中都有效。只有这一个是个问题。你的工作方式很奇怪。我确实得到了我的背景,但它的纵向拉伸是我屏幕大小的3到4倍。我的复选框在下面的某个地方丢失了。:)你能发布你的布局xml文件吗?如果我读对了,你正在使用的图像会被拉伸并在屏幕上显示多次。复选框仍然存在,但不清晰可见?如果是这种情况,您必须为不同的屏幕大小创建多个图像,并将它们放在不同的可绘制文件夹中。您可能需要根据正在使用的屏幕大小在res文件夹中创建新的drawablw文件夹,例如,可绘制的小屏幕、可绘制的普通屏幕等。请参阅链接查看我编辑的回复。尝试使用
android:windowBackground
而不是
android:background
我在游戏的其余部分都有相同的背景图像,它在每一个活动中都有效。只有这一个是个问题。