Android 设置半透明搜索框的三种方式 《H》

来源:互联网 发布:香蕉网络电视tv 编辑:程序博客网 时间:2024/06/06 09:07

方式一:用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透明度值