【问题标题】:Change preference screen's preference item title text color and align left更改首选项屏幕的首选项标题文本颜色并左对齐
【发布时间】:2018-01-03 06:14:21
【问题描述】:

由于某种原因,退出 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】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-02
      • 1970-01-01
      相关资源
      最近更新 更多