android:clipToPadding不能从主题工作,但作为一种风格

时间:2013-07-30 15:42:54

标签: android themes

我在我的应用程序中使用主题来自定义视图,现在一切似乎都运行正常,除了为android:clipToPadding设置GridView,但最令人惊讶的是它的工作原理正如预期的那样,如果我直接设置或使用样式

我的风格看起来像这样(实际上我设置了更多参数,但这与此问题无关):

<style name="GridViewStyle" parent="@android:style/Widget.GridView">
    <item name="android:clipToPadding">false</item>
    <item name="android:paddingTop">@dimen/grid_item_padding</item>
    <item name="android:paddingBottom">@dimen/grid_item_padding</item>
</style>

这是我想要设置它的方式:

<style name="MyTheme" parent="Theme.Sherlock.Light.DarkActionBar">
    <item name="android:gridViewStyle">@style/GridViewStyle</item>
</style>

并且所有参数都有效 - 除了提到android:clipToPadding

现在如果我直接设置样式:

<GridView 
    android:id="@id/grid"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    style="@style/GridViewStyle"
/>

或者我只是这样设置:

<GridView 
    android:id="@id/grid"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clipToPadding="false"
/>

然后它有效。

有没有人知道为什么样式和设置直接有效,但主题不是?

0 个答案:

没有答案