android - 如何更改工具栏标高颜色?
问题描述
在应用程序中有一个更改主题颜色的选项,根据主题颜色,我正在使用以下行更改工具栏背景的颜色:
toolbar.setBackgroundColor(getResources().getColor(R.color.white));
但是,我找不到任何可以帮助我改变海拔颜色的东西。这是工具栏xml:
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="4dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:layout_toLeftOf="@+id/headset"
android:ellipsize="end"
android:maxLines="1"
android:text="@string/contact_us"
android:textColor="@color/gray"
android:textSize="18sp" />
</RelativeLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
请让我知道如何以编程方式进行。
解决方案
设置 AppBarLayout 高程
<android.support.design.widget.AppBarLayout
app:elevation="0dp">
应用主题
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimaryDark">@color/green_tataki</item>
</style>
推荐阅读
- java - 在java中使用泛型循环一个集合
- vue.js - 我只想在特定的 vue 图表上添加标签
- c++ - QDbus 信号不工作(暂停交付)
- flutter - “Null”类型不是“Map”类型的子类型
' 在类型转换中 - python - Python:为什么当我使用 \t 而不是空格字符时,单词会转到下一行?
- r - for 循环内的 ifelse 函数未产生预期结果
- json - HL7v2 到 FHIR 转换默认 CodeSystem 规则不起作用
- pyspark - 更改 Livy 在 EMR 集群中使用的 Python 版本
- ffmpeg - ffmpeg 是否因 h.264 RTP 输出而损坏?
- python - How can i control multiple logins(like admin login and normal login) with flask login_required decorator