【问题标题】:How do I change the color behind the actionbar which appears when using rounded top corners?如何更改使用圆角顶角时出现的操作栏后面的颜色?
【发布时间】:2015-09-07 21:55:22
【问题描述】:

我在自定义操作栏时关注了Googles theme guide。我还在ActionBar 上添加了圆角顶角。问题是圆角后面出现白色。

这是我的活动 main.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#000000"
        android:orientation="vertical" >
</RelativeLayout>

我的样式.xml

<style name="AppBaseTheme" parent="android:Theme">
   <item name="android:windowBackground">@color/black</item>
</style>

这是我的 actionbar_theme.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient 
        android:startColor="#ffc71e"
        android:endColor="#d09e07"
        android:type="linear"
        android:angle="270"/>
    <stroke
        android:width="1px"
        android:color="#333" >
    </stroke>
    <corners
        android:topLeftRadius="7dp"
        android:topRightRadius="7dp">
    </corners>
</shape>

如何更改基础应用程序的背景。我想要黑色。

谢谢。

【问题讨论】:

    标签: android android-actionbar


    【解决方案1】:

    我遇到了同样的问题,这个解决方案对我有用。只需更改活动主题样式的 colorBackground 即可。

    &lt;item name="android:colorBackground"&gt;@android:color/black&lt;/item&gt;

    这是我在清单文件中的活动:

    <activity
        android:name=".MainActivity"
        android:label="@string/title"
        android:theme="@style/MyTheme"
        android:parentActivityName=".MainActivity" >
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value=".MainActivity" />
    </activity>
    

    我的主题样式xml文件,styles.xml

    <resources>
        <style name="MyTheme" parent="Theme.AppCompat.Light">
            <item name="android:colorBackground">@android:color/black</item>
        </style>
    </resources>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-03
      • 1970-01-01
      • 1970-01-01
      • 2011-12-30
      相关资源
      最近更新 更多