您的位置:首页 > 移动开发 > Android开发

Android设置按钮为透明

2016-03-11 16:19 344 查看
设置一个按钮为透明,

(1)修改配置文件

<Button
android:id="@+id/btnAppMore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="详细信息>>"
android:layout_alignParentRight="true"
android:layout_marginLeft="150dp"
android:background="@android:color/transparent"
/>

设置完透明按钮以后,发现按钮不见了……
(2)注意,按钮默认颜色同手机背景色(黑色)一样,按钮的文字默认也为黑色,这里,我们可以通过activity的oncreate()中设置一下按钮的字体颜色:

btn=(Button)findViewById(R.id.btnAppMore);
btn.setTextColor(Color.WHITE);
其实,透明也可以通过Java完成,嘎嘎,btn.setBackgroundColor(Color.TRANSPARENT);即可
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: