android 设置Button或者ImageButton的背景透明
来源:互联网 发布:北京sem优化师 编辑:程序博客网 时间:2024/05/16 02:08
(1)修改XML布局文件大概这样
<Button
android:id=”@+id/btnAppMore”
设置完透明按钮以后,发现按钮不见了……(转载的时候我也不知道作者要表达什么,但是下面的东西就是关键代码 )
半透明< Button Android:background=”#e0000000” … />
透明< Button android:background=”#00000000” … />
*****以下为理论上的解释** 颜色和不透明度 (alpha) 值以十六进制表示法表示。任何一种颜色的值范围都是 0 到 255(00 到 ff)。对于 alpha,00 表示完全透明,ff 表示完全不透明。表达式顺序是“aabbggrr”,其中“aa=alpha”(00 到 ff);“bb=blue”(00 到 ff);“gg=green”(00 到 ff);“rr=red”(00 到 ff)。例如,如果您希望对某叠加层应用不透明度为 50% 的蓝色,则应指定以下值:7fff0000
设置背景图片透明度(超简单)
Java代码
View v = findViewById(R.id.content);//找到你要设透明背景的layout 的id
v.getBackground().setAlpha(100);//0~255透明度值
(2)注意,按钮默认颜色同手机背景色(黑色)一样,按钮的文字默认也为黑色,这里,我们可以通过activity的oncreate()中设置一下按钮的字体颜色:
btn=(Button)findViewById(R.id.btnAppMore);
btn.setTextColor(Color.WHITE);
其实,透明也可以通过Java完成,嘎嘎,btn.setBackgroundColor(Color.TRANSPARENT);即可
摘自huzhigenlaohu的博客阅读全文
0 0
- Android 设置Button或者ImageButton的背景透明 半透明 透明
- android 设置Button或者ImageButton的背景透明 半透明 透明
- android 设置Button或者ImageButton的背景透明 半透明 透明
- android 设置Button或者ImageButton的背景透明 半透明 透明
- android 设置Button或者ImageButton的背景透明 半透明 透明
- android 设置Button或者ImageButton的背景透明 半透明 透明
- android 设置Button或者ImageButton的背景透明 半透明 透明
- android 设置Button或者ImageButton的背景透明 半透明 透明
- android 设置Button或者ImageButton的背景透明 半透明 透明
- Android中设置Button或者ImageButton的背景透明
- android 设置Button或者ImageButton的背景透明 半透明
- android 设置Button或者ImageButton的背景透明
- android 设置Button或者ImageButton的背景透明
- android 设置Button或者ImageButton的背景透明
- android 设置Button或者ImageButton的背景透明
- android布局设置Button或者ImageButton的背景透明 半透明 透明
- 安卓笔记android 设置Button或者ImageButton等空间的背景透明
- ImageButton去边框&Button或者ImageButton的背景透明
- linux进程间通信-信号量
- linux中软件安装
- [数学理论]不同分布训练集、验证集、测试集处理
- LeetCode-Two Sum
- java常用设计模式(观察者模式)
- android 设置Button或者ImageButton的背景透明
- 类 手机
- 编写程序,用0-1之间的随机数来模拟扔硬币试验,统计扔1000次后出现正反面的次数并输出。
- StatelistDrawable 状态选择器失灵
- UVA10891(区间DP)
- 【BZOJ1087】【SCOI2005】互不侵犯
- 第一次写
- OSPF协议
- Java中System.arraycopy()和Arrays.copyOf()的区别