我认为更多“全局”样式总是被更多“本地”样式所覆盖。例如,如果我将所有按钮重新定义为textSize = 40dip(将该样式应用为应用程序的主题),然后将另一个样式应用于指定textSize = 10dip的特定按钮,那么该特定Button应该获得10dip textSize。样式,minHeight/maxHeight:我无法让maxHeight覆盖主题minHeight
这就是它的工作原理,通常。但是,当涉及到maxHeight时。这里是场景:
在我的 styles.xml我有一个样式,我继承了默认的Button并更改textSize和minHeight,然后另一个样式设置了一些其他值(但也从Button继承),就像这个:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Button" parent="@android:style/Widget.Button">
<item name="android:textSize">26dip</item>
<item name="android:minHeight">60dip</item>
</style>
<style name="ButtonHeader" parent="@android:style/Widget.Button">
<item name="android:textSize">18dip</item>
<item name="android:minWidth">70dip</item>
<item name="android:maxHeight">10dip</item>
</style>
</resources>
我将第一个Style应用为我的Activity的一个主题,它使所有按钮变大(minHeight = 60dip)。但我有一个“标题”(其中有一些其他按钮),我不想拥有60dip的minHeight,而对于这些按钮,我想使用 ButtonHeader,将maxHeight设置为10dip。
在我 header.xml它看起来像这样:
<Button style="@style/ButtonHeader" android:text="UPP" android:id="@+id/Header_Button_UPP" android:layout_width="wrap_content" android:layout_height="wrap_content" ></Button>
<Button style="@style/ButtonHeader" android:text="ALT" android:id="@+id/Header_Button_ALT" android:layout_width="wrap_content" android:layout_height="wrap_content" ></Button>
<Button style="@style/ButtonHeader" android:text="NAV" android:id="@+id/Header_Button_NAV" android:layout_width="wrap_content" android:layout_height="wrap_content" ></Button>
<Button style="@style/ButtonHeader" android:text="HIS" android:id="@+id/Header_Button_HIS" android:layout_width="wrap_content" android:layout_height="wrap_content" ></Button>
我specificly造型的按钮,覆盖了 “全球” 的主题。它在一些地方起作用;这些标题按钮的textSize被正确设置为18dip,但maxHeight被忽略 - 这些按钮的高度也增加到60dip。
如果我在ButtonHeader的样式中设置android:minHeight =“100dip”,那么标题中的按钮将增加到100dip,覆盖主题。 但是,如上所述,当我有android:maxHeight时,没有任何反应。
我错过了什么?
没有人有线索? =) – Ted 2010-01-08 21:02:40