【发布时间】:2011-02-10 06:36:11
【问题描述】:
我有一个按钮。当我按下按钮时,我必须将文本设置为粗体,否则正常。所以我写了粗体和正常的样式。
<style name="textbold" parent="@android:style/TextAppearance">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textStyle">bold</item>
</style>
<style name="textregular" parent="@android:style/TextAppearance">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textStyle">normal</item>
</style>
现在我有一个 button_states.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="true"
style="@style/textbold" />
<item android:state_focused="false" android:state_pressed="true"
style="@style/textregular" />
<item style="@style/textregular" />
</selector>
在此按钮的布局中,我还必须将背景设置为透明...我该怎么做?我的布局代码是:
<Button android:id="@+id/Btn" android:background="@drawable/button_states" />
如何在我的样式中包含透明背景?
【问题讨论】:
-
这么多好的答案现在可以被接受了...
-
查看this answer here 制作带边框的透明按钮
-
' 你为什么不直接使用 TextView 并在它的 onClick 上调用操作呢?
标签: android