最近使用PopupWindow时,遇到个问题,想在弹出PopupWindow非全屏显示,要留有边距左、右12dp
解决方案:在布局里设置,如
内容全部在LinearLayout中,最外面再包一层,设置marginLeft和MarginRight
即
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="12dp"
android:paddingRight="12dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/shape_corners_button"
android:orientation="vertical"
>
实际内容
</LinearLayout>
</FrameLayout>