安卓preference屏幕布局布局、屏幕、preference

2023-09-06 03:35:44 作者:爱情是一场赌局

我有以下的preference屏幕在我的应用程序

I have the following preference screen in my app

<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<EditTextPreference
android:key="edittexvalue"
android:id="@+id/edittextvalue"
android:title="Title Here"
android:summary="Summary Here" 
android:defaultValue="Some Value"/>
<Preference
android:key="customPref"
android:title="Title Here"
android:summary="Summary Here"/>
</PreferenceScreen>

所有的作品就好了但是我的应用程序,我有自定义的背景和文字颜色/大小,但我无法弄清楚如何格式化preferenceScreen我想你这点在其他XML?但不能找出codeI需要,哪些应该作出改变。主要关注的是背景色的文字是好的我猜,但背景少了点我的应用程序的其余部分不匹配。所以,我想设置自定义背景色可以说,红色对于现在(#FF0000)

All of that works just fine however my app i have custom backgrounds and text colors/sizes but i can't figure out how to format the PreferenceScreen I assume you point this at another xml? but can't figure out the code i need and what changes should be made. The main concern is the background color the text is fine i guess but the background just doesn't match the rest of my app. So i'd like to set a custom background color lets say red for now (#ff0000)

我要感谢的人,可以帮助我解决这个问题。

I thank anyone that can help me with this problem

推荐答案

您可以到主题适用于它在你的清单,例如:

You can to apply a theme to it in your manifest, for example

<activity android:name=".Settings"
     android:theme="@style/YourStyle"/>

和您的 styles.xml (如果你没有之一,在价值观文件夹中创建它) 您可以修改任何你需要

and in your styles.xml (if you dont have one, create it in the values folder) you can modify whatever you need

例如

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="YourStyle" parent="android:Theme.Light">
    <item name="android:listViewStyle">@style/Widget.ListView</item>
    <item name="android:windowNoTitle">true</item>
</style>

<style name="Widget" parent="android:Widget">
</style>

<style name="Widget.ListView">
    <item name="android:background">@color/white</item>
    <item name="android:divider">@color/gray_division</item>
    <item name="android:dividerHeight">2dip</item>       
</style>
</resources>

我希望这有助于

I hope this helps

 
精彩推荐