使用主题为preferences屏幕屏幕、主题、preferences

2023-09-04 23:59:31 作者:死守一世寂寞

我想改变preferences屏幕的外观为一个应用程序,我工作。在某些手机上的preferences非常透明,这是相当困难的阅读preferences方案,所以我要改变的视觉效果吧。

I want the change the look of the preferences screen for an app I am working on. On some phones the preferences are very translucent and it is quite difficult to read the preferences scheme, so I am going to change the visuals for it.

我的问题是我如何申请一个主题,以preferences计划?或者做不到这一点,我怎么能更改显示的各种preferences文本的颜色。

My question is how can I apply a theme to the preferences scheme? Or failing that, how can I change the text color that show up for the various preferences.

在我目前的版本,我的preferences布局的XML文件开头:

In my current version, my preferences layout xml file starts with:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#ffa0a0a0">

此背景颜色给了我一个可以接受的灰色,但我会preFER使用一个主题。

This background color gives me an acceptable gray, but I would prefer to use a theme.

我试图把一个应用几个不同的主题在preferences XML和preferences布局xml和没有这已经显示出任何影响。我也试着设置andoid:文字颜色为单个preferences项目和布局,并且没有任何影响

I tried putting a applying a couple of different themes in the preferences xml and the preferences layout xml and none of this has shown any effect. I also tried setting andoid:textColor for the individual preferences items and in layout and that had no effect.

那么,如何(通过使用一个主题preferably)修改的视觉效果为preferences计划?

So how does one modify the visuals for the preferences scheme (preferably by using a theme)?

在此先感谢,

周杰伦

推荐答案

基本的东西是:

一个主题,你的preferences活动定义样式为preference部件和其他东西。看看第一个主题themes.xml - 这个定义窗口背景,文字样式和preference样式( preferenceScreenStyle , preferenceCategoryStyle 等) 有些款式每个preference小部件(这是在的themes.xml 引用)。例如,在styles.xml它们定义了 preference.Category preference。preferenceScreen 的风格。 应用主题,你的活动。在您的清单中改变你的开放的活动标记为您的preferences活动&LT;活动机器人:主题=@风格/ CustomTheme...... A theme for your preferences activity which defines styles for the preference widgets and other things. Take a look at the first theme in themes.xml - this defines the window background, text styles and the preference styles (preferenceScreenStyle, preferenceCategoryStyle etc) Some styles for each of the preference widgets (which are referenced in themes.xml). For instance in styles.xml they define the Preference.Category and Preference.PreferenceScreen styles. Apply the theme to your Activity. In your manifest change your opening activity tag for your preferences activity to <activity android:theme="@style/CustomTheme"...

如果你想继承默认的Andr​​oid风格,然后只是覆盖一些人,然后添加父=@安卓风格/主题开口&LT;花柱... 的主题标签

If you want to inherit the default Android styles and then just override some of them, then add parent="@android:style/Theme" to the opening <style... tag of your theme.

看看应用样式和主题,获取更多信息。

Take a look at Applying Styles and Themes for more info.

 
精彩推荐
图片推荐