没什么android开发经验的朋友来说,实现透明效果是有一定难度的,我看见麦子学院android开发视频上面讲了三种方法来实现透明效果,这三种方法非常不错,嘿嘿,就抄下来分享给大家。
1、设置alpha
View v = findViewById(R.id.content);/到你要设透明背景的layout 的id
v.getBackground().setAlpha(100);//0~255透明度值
2、用ARGB来控制
半透明<Button android:background="#e0000000" />
透明<Button android:background="#00000000" />
3、用android系统自带的透明效果
android:background="@android:color/transparent"
例如设置按钮
<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" />
1、设置alpha
View v = findViewById(R.id.content);/到你要设透明背景的layout 的id
v.getBackground().setAlpha(100);//0~255透明度值
2、用ARGB来控制
半透明<Button android:background="#e0000000" />
透明<Button android:background="#00000000" />
3、用android系统自带的透明效果
android:background="@android:color/transparent"
例如设置按钮
<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" />
本文介绍了三种实现Android应用中透明效果的方法:通过设置View的alpha值、使用ARGB颜色值和利用Android系统自带的透明颜色资源。这些方法适用于希望为应用增加透明度效果的开发者。
7577

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



