android 中遮罩效果有多种实现方法:
1、framelayout中添加一层,覆盖在所有层上
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#fff">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#86222222"
android:orientation="horizontal" >
<TextView
android:id="@+id/titleTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="遮罩效果"
android:textColor="#ff0000" />
<Button
android:id="@+id/unfoldButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="显示遮罩" />
</RelativeLayout>
</FrameLayout>
public class ShadeActivity extends Activity {
// 设置是否展开
private boolean isFolded = true;
// 设置控件
private FrameLayout layout = null;
private Button u