方式一:用android系统的透明效果Java代码
android:background="@android:color/transparent"
例如设置Button:
<Button android:background="@android:color/transparent"
android:text="@+id/Button01"
android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ffffff" />
方式二:用ARGB来控制
//Java代码
半透明<Button android:background="#e0000000" />
透明<Button android:background="#00000000" />
方式三:设置alpha
//Java代码
View v = findViewById(R.id.content);//找到你要设透明背景的layout 的id
v.getBackground().setAlpha(100);//0~255透明度值
本文介绍了三种在Android中实现视图透明效果的方法:使用系统提供的透明颜色资源、通过ARGB值自定义透明度以及动态调整View的alpha值。这些方法适用于按钮等UI组件的背景设置。
1430

被折叠的 条评论
为什么被折叠?



