版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_35008719/article/details/52504023
修改Button的背影颜色后实在有些难看,让其与背景相融合,是设置呈透明或半透明状就好看多了。
超级简单,让你的按钮不再那么不堪入目
有两种方法可供选择:
第一种:在布局文件里修改
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:background="#00000000"
/> 透明
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:background="#e0000000"
/> 半透明
第二种:在Java文件里进行修改
View v = findViewById(R.id.buttona);//找到要设透明度的控件或布局
v.getBackground().setAlpha(0);//0~255是透明度值 其中0是全透明