Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android工具栏菜单项背景_Android_Xml_Android Styles_Android Menu - Fatal编程技术网

Android工具栏菜单项背景

Android工具栏菜单项背景,android,xml,android-styles,android-menu,Android,Xml,Android Styles,Android Menu,如何实现Youtube应用程序屏幕截图右上角的用户名图标在Youtube应用程序中的样式效果 目前,我有以下应用程序的样式 <style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar"> <item name="colorPrimary">@color/primary</item> <item name="colorPrimaryDark">@

如何实现Youtube应用程序屏幕截图右上角的用户名图标在Youtube应用程序中的样式效果

目前,我有以下应用程序的样式

<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/primary_dark</item>
    <item name="colorAccent">@color/color_accent</item>
    <item name="otpViewStyle">@style/OtpWidget.OtpView</item>
    <item name="windowActionBar">false</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:actionMenuTextAppearance" >@style/home_menu_style</item>
</style>

<style name="home_menu_style" parent="AppTheme">
    <item name="android:textSize">20sp</item>
    <item name="android:textStyle">bold</item>
    <item name="android:actionMenuTextColor">@color/white</item>
</style>

@颜色/原色
@颜色/原色/深色
@颜色/颜色口音
@style/OtpWidget.OtpView
假的
真的
@样式/主菜单样式
20便士
大胆的
@颜色/白色
另一个问题是文本颜色是黑色,而不是白色。我已经在样式和工具栏定义中将文本颜色定义为白色

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/primary"
        android:minHeight="?attr/actionBarSize"
        android:theme="@style/AppTheme.AppBarOverlay"
        app:popupTheme="@style/AppTheme.PopupOverlay"
        app:titleTextColor="@color/white">
    </androidx.appcompat.widget.Toolbar>

制作一个如下所示的可绘制文件

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid
    android:color="#48b3ff"/>

像这样使用

<style name="home_menu_style" parent="AppTheme">
<item name="android:textSize">20sp</item>
<item name="android:textStyle">bold</item>
<item name="android:backGround">@drawable/your_custom_drawable</item>
<item name="android:actionMenuTextColor">@color/white</item>

20便士
大胆的
@可绘制/您的\u自定义\u可绘制
@颜色/白色

问题的答案在以下链接中:

这是同一个问题,有更多的背景