[英]How can I change the color of AlertDialog title and the color of the line under it
[英]How can I change the color of a CollapsibleToolbar title?
因此,我在處理許多不同的屬性方面苦苦掙扎了幾天,但仍然無法弄清楚如何更改折疊工具欄標題的文本顏色。 對此有什么看法嗎? 這是我一直在試驗的一個非常簡單的布局。 app:titleTextColor="@color/colorPrimary"
沒有效果。
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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="match_parent"
tools:context=".MainActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/appBarLayout"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|snap|exitUntilCollapsed"
app:contentScrim="@color/colorPrimary"
app:expandedTitleGravity="center|top"
app:title="@string/app_name"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="250dp"
android:src="@drawable/zebra"
android:scaleType="centerCrop"
android:contentDescription="@string/zebras"
/>
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark"
app:titleTextColor="@color/colorPrimary"
/>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
在styles.xml中添加樣式
<style name="CollapsedAppBarText" parent="@android:style/TextAppearance.Medium">
<item name="android:textSize">16sp</item>
<item name="android:textColor">@color/blue</item>
<item name="android:textStyle">normal</item>
</style>
然后活動/片段像這樣使用
collapsingToolbar = findViewById<View>(R.id.collapsing_toolbar) as CollapsingToolbarLayout
collapsingToolbar?.setCollapsedTitleTextAppearance(R.style.CollapsedAppBarText)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.