【问题标题】:how to apply multiple Styles in android in same xml如何在同一个xml中应用多个样式在android中
【发布时间】:2013-07-15 14:31:51
【问题描述】:

您好,我制作了一个 android 程序,其中我为所有活动放置了一个九路径按钮,但我为它应用了一种样式,但对于其他活动,需要不同样式的边距...所以。我有我的一种风格,如下所示:那么我可以在同一个 style.xml 文件中为同一个元素放置另一种风格吗? 我的代码如下:

<style name="button">
        <item name="android:layout_width">fill_parent</item>
        <item name="android:layout_height">wrap_content</item>
         <item name="android:layout_marginLeft">30dp</item>
            <item name="android:layout_marginRight">30dp</item>
        <item name="android:layout_weight">1</item>
        <item name="android:tag">200</item>
        <item name="android:padding">7dp</item>
        <item name="android:textSize">15dp</item>
        <item name="android:textColor">#f5f0eb</item>
    </style>

【问题讨论】:

    标签: android styles margin


    【解决方案1】:

    你可以通过做这样的事情来制作子样式

    <style name="otherButton" parent="button">  
        <item name="android:layout_marginLeft">50dp</item>    
    ...
    

    此样式继承了其父样式的所有内容。您在子样式中定义的所有内容都将覆盖之前定义的任何属性。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-16
      • 1970-01-01
      • 1970-01-01
      • 2015-05-31
      • 2017-11-14
      • 2011-06-18
      • 1970-01-01
      • 2017-05-25
      相关资源
      最近更新 更多