首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >按钮背景为透明

按钮背景为透明
EN

Stack Overflow用户
提问于 2011-02-10 14:36:11
回答 10查看 299.4K关注 0票数 199

我有一颗纽扣。当我按下按钮时,我必须将文本设置为粗体,否则就是正常的。所以我写了一些粗体和普通的样式。

代码语言:javascript
复制
<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 as:

代码语言:javascript
复制
<?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> 

在此按钮的布局中,我必须将背景设置为透明的too...How。我会这样做吗?我的布局代码是:

代码语言:javascript
复制
<Button android:id="@+id/Btn" android:background="@drawable/button_states" />

如何在我的风格中包含透明的背景?

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4954102

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档