如何解决selectableItemBackground在PreferenceFragmentCompat项目Androidx中不起作用
我的PreferenceFragmentCompat
中都有DrawerLayout
和带有NavigationView
的{{1}}。
我尝试使用MainActivity
更改项目背景。它可以在?selectableItemBackground
中的TextView
上运行。
NavigationView
(暗模式:深灰色,亮模式:白色)
但是它不适用于我的<TextView
android:id="@+id/feedback"
android:layout_width="match_parent"
android:layout_height="52dp"
android:background="?selectableItemBackground"
android:clickable="true"
android:focusable="true"
... />
(始终为白色)。
这是我的主题,我使用自己的布局而不是默认的首选项布局。
我的活动主题。
PreferenceFragmentCompat
我的首选项布局。根是<style name="MyTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="preferenceTheme">@style/MyPreferenceTheme</item>
</style>
<style name="MyPreferenceTheme" parent="@style/PreferenceThemeOverlay">
<item name="preferenceScreenStyle">...</item>
<item name="preferenceFragmentCompatStyle">...</item>
<item name="preferenceFragmentStyle">...</item>
<item name="preferenceCategoryStyle">...</item>
<item name="preferenceStyle">@style/MyPreferenceStyle</item>
<item name="checkBoxPreferenceStyle">...</item>
<item name="switchPreferenceCompatStyle">...</item>
<item name="preferenceCategoryTitleTextAppearance">...</item>
<item name="switchPreferenceStyle">...</item>
<item name="dialogPreferenceStyle">...</item>
<item name="editTextPreferenceStyle">...</item>
<item name="preferenceFragmentListStyle">...</item>
</style>
<style name="MyPreferenceStyle">
<item name="android:layout">@layout/preference_item</item>
</style>
。
LinearLayout
我如何使其工作?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?selectableItemBackground"
android:baselineAligned="false"
android:clickable="true"
android:clipToPadding="false"
android:focusable="true"
...
解决方法
请在线性布局中给出完整的值。
android:background="?attr/selectableItemBackground"
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。