問題描述
我有一個 PreferenceCategory
xml 文件,我已經在其中定義了所有首選項,我從擴展 PreferenceActivity
的類中調用它.我無法設置我的設置屏幕的背景,這個屏幕是在下面顯示的 xml 文件的幫助下顯示的.請看我已經定義了android:background="#041A37"
,屏幕仍然保持默認顏色:黑色.
I have a PreferenceCategory
, xml file and I have defined all preferences in it, I call this from class that extends PreferenceActivity
. I am unable to set the background of my settings screen, this screen is displayed with help of xml file shown below. Please see that I have already defined the android:background="#041A37"
, still the screen remains default color: black.
public class MyPreferenceActivity extends PreferenceActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
Context mContext=super.getBaseContext();
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.layout.preference);
//v.setBackgroundColor(Color.rgb(4, 26, 55));
}
}
<小時>
preference.xml 是
preference.xml is
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#041A37" >
<PreferenceCategory>
<com.dropcall.SeekBarPreference
android:background="#041A37"
android:defaultValue="5"
android:key="@string/Interference_Delay"
android:progressDrawable="@drawable/seekbardrawable"
android:title="Seconds Delay until intereference" />
<com.dropcall.SeekBarPreference2
android:defaultValue="30"
android:key="@string/Drop_Delay"
android:progressDrawable="@drawable/seekbardrawable"
android:title="Seconds delay until drop" />
<CheckBoxPreference
android:background="@drawable/state_normal"
android:defaultValue="true"
android:key="@string/Drop_Option"
android:title="Close after call drop" />
<CheckBoxPreference
android:background="@drawable/state_normal"
android:defaultValue="true"
android:key="@string/Timer_Option"
android:title="Start timers on launch" />
</PreferenceCategory>
</PreferenceScreen>
<小時>
雖然我在每個文件中都設置了 android:background="#041A37"
,但背景并沒有變成海軍藍或任何其他顏色.它保持默認顏色,黑色.如何更改背景顏色.請讓我知道任何指針/提示,如果您遇到同樣的問題,請告訴我您為設置背景顏色所做的更改.
Although I have set android:background="#041A37"
in every file, the background doesn't turn into navy blue, or any other color for that matter. It remains default color, black. How to change the background color. Please let me know any pointers / hints , if you had faced same issue let me know what changes you made to set the background color.
推薦答案
這對我有用
getListView().setBackgroundColor(Color.TRANSPARENT);
getListView().setCacheColorHint(Color.TRANSPARENT);
getListView().setBackgroundColor(Color.rgb(4, 26, 55));
這篇關于更改首選項的背景顏色的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!