在 Android 中实现弹出层方式很多,下面介绍几种常用的
1.通过FrameLayout模拟弹出层
优点:实现简单,布局也比较好写
缺点:位置在上下左右比较好,其他复杂的布局要写大量的点击事件来阻止点击向下传递
比如实现下面的效果:
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_width="match_parent"
android:layout_height="match_parent">
android:id="@+id/but01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click"/>
android:id="@+id/popouter"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="#AAA"
android:alpha="0.5"
android:id="@+id/popinner1"
android:layout_weight="5">
android:id="@+id/popinner2"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="0dp"
android:bac