我有一个按钮。当我按下按钮时,我必须使文本为粗体,否则正常。所以我写了大胆的&正常的样式。按钮背景为透明
<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" />
如何将背景作为我的风格透明?
所以许多好的答案现在可能接受...... – QED 2015-08-30 01:11:29
退房[这个答案在这里(http://stackoverflow.com/questions/12856661/how-to-make-button-transparent -in-my-app-yet-visible#answer-12856901)制作具有边框的透明按钮 – 2016-03-31 22:10:02
'为什么不使用TextView并在onClick上调用动作? – 2016-05-07 13:05:32