【问题标题】:How to place a DialogFragment above/below another DialogFragment?如何将 DialogFragment 放在另一个 DialogFragment 上方/下方?
【发布时间】:2020-11-17 09:40:59
【问题描述】:

我正在尝试在 Dialog 片段上方/下方显示一些内容,但我不希望这 2 个内容位于相同的 XML 布局上,因为其中一个 DialogFragment 比另一个更宽,并且如果它们位于相同的 XML 上它看起来很奇怪。所以我试图实现这样的目标: picture

我在这里找到了这个问题:How to raise one DialogFragment above another?,但我认为这不适用于我的用例。

【问题讨论】:

    标签: android android-fragments android-dialogfragment


    【解决方案1】:

    这里不需要两个不同的对话框。只为一个对话框充气,里面有两张卡片。

    <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
    
        <com.google.android.material.card.MaterialCardView ... />
    
        <com.google.android.material.card.MaterialCardView ... />
    
    </androidx.constraintlayout.widget.ConstraintLayout>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-13
      相关资源
      最近更新 更多