DialogFragment

直播间私信.jpg

私信功能一般 app 都会有2个入口

  1. 在直播间以外,普通的全页面。
  2. 在直播间,半屏。

实现

  1. popupwindow
    因为 pop 中不能插入一个 fragment(可能我才疏学浅,如有方法请留言告知,谢谢),基本上需要粘贴遍 LetterFragment 的代码,很不优雅。
  2. DialogFragment
    ta 可以直接插入一个 fragment,所以直接使用已经写好的 LetterFragment 。可能有点抽象,我直接贴出布局文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="350dp"
    android:orientation="vertical"
    >

    <FrameLayout
        android:id="@+id/fl_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</LinearLayout>
  1. BottomSheetDialogFragment
    基于以上一点,我们可以让 LetterDialog 继承 BottomSheetDialogFragment。ta是什么自行搜索。ta有个很好的特性:可以随着手势伸缩、关闭。
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容