change background color of Preference(更改首选项的背景颜色)
问题描述
我有一个 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="U2Vjb25kcyBEZWxheSB1bnRpbCBpbnRlcmVmZXJlbmNl" />
<com.dropcall.SeekBarPreference2
android:defaultValue="30"
android:key="@string/Drop_Delay"
android:progressDrawable="@drawable/seekbardrawable"
android:title="U2Vjb25kcyBkZWxheSB1bnRpbCBkcm9w" />
<CheckBoxPreference
android:background="@drawable/state_normal"
android:defaultValue="true"
android:key="@string/Drop_Option"
android:title="Q2xvc2UgYWZ0ZXIgY2FsbCBkcm9w" />
<CheckBoxPreference
android:background="@drawable/state_normal"
android:defaultValue="true"
android:key="@string/Timer_Option"
android:title="U3RhcnQgdGltZXJzIG9uIGxhdW5jaA==" />
</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));
这篇关于更改首选项的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:更改首选项的背景颜色


- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01