android - 为什么我的 Preferences 类中的文本被删掉了?
问题描述
我不明白为什么这里的 wrap_content 在自定义“首选项”中不起作用
看这张图片:
文本应保持可见。这是我必须在PreferenceScreen
xml 文件中进行的一些设置吗?
这是xml布局:
<TextView
android:id="@+id/textView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:text="@string/pref_category_remote_battery_title"
android:textAppearance="?android:attr/textAppearanceListItem"
android:textColor="@color/default_400"
app:layout_constraintBottom_toTopOf="@+id/textView2"
app:layout_constraintEnd_toStartOf="@+id/guideline3"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_default="wrap" />
<TextView
android:id="@+id/textView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:text="@string/pref_category_remote_battery_switch_summ"
android:textAppearance="?android:attr/textAppearanceSmall"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/guideline3"
app:layout_constraintHorizontal_bias="0.02"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView"
app:layout_constraintWidth_default="wrap" />
<android.support.v7.widget.SwitchCompat
android:id="@+id/switch_compat"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="24dp"
android:layout_marginBottom="8dp"
android:checked="false"
android:textOff="OFF"
android:textOn="ON"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/guideline3"
app:layout_constraintTop_toTopOf="parent"
app:showText="true" />
<android.support.constraint.Guideline
android:id="@+id/guideline3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.75" />
这是首选项 xml:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<com.sun.power.extended.preferences.ShowRemoteDataPreference android:key="@string/pref_key_category_remote_battery_switch" />
<com.sun.power.extended.preferences.ShowStatPreference android:key="@string/pref_key_show_stat" />
</PreferenceScreen>
解决方案
推荐阅读
- python-appium - 如何使用 Appium python 自动按下完成按钮
- reactjs - 使用 HOC 使用 div 自动包装所有链接和按钮
- ios - iOS:具有关键帧的交互式动画在手势结束时未正确恢复
- python - ValueError:为 plotly.graph_objs.Heatmap 类型的对象指定的属性无效:'scl'
- decomposition - 得到一个整数的素因子分解,
- javascript - 正则表达式匹配任一单词,但准确的单词
- c++ - 在 C/C++ 中快速获得 10 的 n(10^n) 次幂
- nginx - 烧瓶重定向在 Nginx 代理上搞砸了
- javascript - Javascript将日期舍入到最接近的完整日期
- excel - 是否可以将一系列单元格加入一个单元格并删除 0 值?