更改首选项屏幕的首选项标题文本颜色并向左对齐

问题描述 投票:0回答:1

出于某种原因,退出Button正在被推向正确。怎么解决这个?我在自定义布局的TextViewLinearLayout中做的任何事情都不起作用。我只想更改此首选项的颜色

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <TextView
        android:id="@android:id/title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="@color/coral"
        android:textSize="16sp"
        android:text="@string/title_sign_out"/>
</LinearLayout>

我在这里使用布局

   <PreferenceCategory android:title="@string/title_section">

        <Preference android:key="@string/key_account" />

        <Preference
            android:key="@string/key_logout_btn"
            android:widgetLayout="@layout/pref_account_text" />

    </PreferenceCategory>

您可以在下面看到截图。

preference layout

android preference preferencefragment android-text-color
1个回答
1
投票

终于弄清楚了。当我尝试使用布局属性时,它没有显示任何内容,因为我在自定义布局的textview中设置了android:id="@android:id/title"

所以删除android:id="@android:id/title"并将首选项自定义布局设置为android:layout =“@ layout / pref_account_text”而不是widgetLayout解决了它

© www.soinside.com 2019 - 2024. All rights reserved.