【问题标题】:Button 3D-style Text padding按钮 3D 样式文本填充
【发布时间】:2013-07-20 20:46:39
【问题描述】:

我的主屏幕上有一些按钮。这些都是由一个buttonstyle xml设计的:

<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:state_pressed="false"             android:drawable="@drawable/button_faq" />
<item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/button_faq_pushed" />
<item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/button_faq_pushed" />
<item android:drawable="@drawable/button_faq" />
</selector>

为了使其更 3D,如果按下按钮,我想将 Button-Text 向下 4px。

我该如何实现?

【问题讨论】:

  • “button_faq_pushed”是图像还是 xml?

标签: android button text styles padding


【解决方案1】:

尝试添加形状并使用填充值:

<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/button_faq" android:state_focused="true" android:state_pressed="false"/>
    <item android:drawable="@drawable/button_faq_pushed" android:state_focused="true" android:state_pressed="true">
            <shape>
                 <padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp" />
            </shape>
    </item>
    <item android:="" android:drawable="@drawable/button_faq_pushed" android:state_focused="false" android:state_pressed="true"/>
    <item android:drawable="@drawable/button_faq"/>

</selector>

【讨论】:

  • 您是否根据需要更改了 10dp 值?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-07-07
  • 2021-12-28
  • 1970-01-01
  • 2020-05-22
  • 2012-12-07
  • 2012-05-29
  • 1970-01-01
相关资源
最近更新 更多