编写xml文件没有任何要求,如同平时写自定义View或Activity那样编写您的布局即可。
在编写xml时,我们仅关注我们要展示的内容,背景蒙层相关的内容无需在此编写。
根布局的layout_gravity功能同BasePopup的Gravity功能 ,决定您的Popup展示在哪个位置

示例

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:tools="http://schemas.android.com/tools"
  4. android:layout_width="150dp"
  5. android:layout_height="150dp"
  6. android:layout_gravity="center"
  7. android:background="@drawable/bg_round_white_8dp">
  8. <TextView
  9. android:id="@+id/tv_desc"
  10. android:layout_width="match_parent"
  11. android:layout_height="match_parent"
  12. android:gravity="center"
  13. android:padding="@dimen/default_padding"
  14. android:textColor="@color/text_black2"
  15. android:textSize="@dimen/text_large"
  16. tools:text="动画展示" />
  17. </FrameLayout>

弹窗效果

布局.png