【问题标题】:change in activity style deforms button活动风格的改变使按钮变形
【发布时间】:2012-09-23 22:38:53
【问题描述】:

我想更改我的操作栏的样式(更改颜色和文本字体),因此设置我的清单和样式 XML,如下所示:

清单:(应用程序)

android:theme="@style/ArbuckleAppTheme"

样式表:

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <style name="ArbuckleAppTheme" parent="@android:style/Theme.Holo.Light">
        <item name="android:actionBarStyle">@style/ActionBarStyle</item>
    </style>

    <style name="ActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar">
        <item name="android:background">@color/handler_noorder_startcolor</item>
        <item name="android:textColor">@color/handle_noorder_textcolor</item>
    </style>

</resources>

问题是我的一个按钮(在滑动抽屉内)变得更大了。我尝试更改布局值等,但现在可用。

这里是按钮周围的 xml:

 <Button
                android:id="@+id/bCancel"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_alignParentLeft="true"
                android:text="Cancel"
               android:background="@drawable/cancel_singleitem_background"
                android:textSize="12dp"
                android:padding="5dp" 
                android:layout_marginLeft="2dp"
                android:layout_marginRight="2dp"/>

在我的应用程序的主要部分有一个相同的按钮 - 它不会改变形状。 我想弄清楚为什么这个按钮的形状完全搞砸了。如果需要,很高兴添加更多代码 - 我想我会先从直接代码开始。

【问题讨论】:

  • 我刚刚注意到,当我在 XML 中输入我的样式时,自动完成功能不适用于 android:actionBarStyle。

标签: android button styles android-actionbar


【解决方案1】:

我想通了!

您可以从应用程序主题中删除父属性,这将删除在整个应用程序中强加的 holo.light 格式。

所以现在的代码是:

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <style name="ArbuckleAppTheme" >
        <item name="android:actionBarStyle">@style/ActionBarStyle</item>
    </style>

    <style name="ActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar">
        <item name="android:background">@color/handler_noorder_startcolor</item>
        <item name="android:textColor">@color/handle_noorder_textcolor</item>
    </style>

</resources>

顺便说一句,我所说的强加(按钮变大)是因为 Google 正试图对应用程序开发施加最低标准 - 其中包括最小的按钮。 48 像素。

我从中学到了很多 - 希望这对你们中的一些人来说是个新闻,所以我可以回馈。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-11
    • 2019-05-08
    • 1970-01-01
    • 2015-10-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多