在设计工具栏视图以使其适用于API 21及以下版本时存在一些问题,但我认为我有这个styles.xml
@color/colorPrimary
@color/colorPrimaryDark
@color/colorPrimary
@color/white
@color/grey
这在我的screen1.xml工具栏中
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:theme="@style/AppToolbarTheme"
app:popupTheme="@style/AppPopupToolbarTheme"
android:id="@+id/app_bar">
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/toolbar_text"
android:textColor="?android:textColorPrimary"
android:gravity="center"/>
上面的“?android:textColorPrimary”在API< 21,然后回到深色文本颜色而不是我的@ color / white.
但是我仍然认为可以通过使用setSupportActionBar((工具栏)findViewById(R.id.app_bar))“自动生成”TextView标题;在Activity.onCreate()中,我可以看到TextView跟随我的textColorPrimary.
> android应该是什么:textColor =?要么
>如何从ActionBar支持中看到生成的TextView(如浏览器F12)?所以我也可以申请.
解决方法:
textcolor属性的正确值应为:
android:textColor="?android:attr/textColorPrimary"
标签:android,android-layout,material-design
来源: https://codeday.me/bug/20190623/1275190.html