用CardView代替FrameLayout可以使对话框更宽?

时间:2019-05-19 16:26:25

标签: android android-layout android-cardview android-framelayout materialcardview

我有一个Framelayout,其代码将圆角用作框架布局背景

  <FrameLayout
      android:id="@+id/popover"
      style="@style/popover_style"
      android:layout_width="@dimen/popover_width"
      android:layout_height="0dp"
      android:layout_marginBottom="@dimen/popover_bottom_margin"
      android:layout_marginLeft="@dimen/popover_side_margin"
      android:layout_marginRight="@dimen/popover_side_margin"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintHeight_default="wrap"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toTopOf="@+id/popover_top_guideline"
      app:layout_constraintVertical_bias="0">
  </FrameLayout>

    ShapeAppearanceModel shapeAppearanceModel = new ShapeAppearanceModel();
    shapeAppearanceModel.setAllCorners(
        CornerFamily.ROUNDED,
        context.getResources().getDimensionPixelSize(R.dimen.corner_radius));
    ViewCompat.setBackground(
        popover, getPopoverViewShapeDrawable(getContext(), shapeAppearanceModel));

我已将其替换为<androidx.cardview.widget.CardView>

 <androidx.cardview.widget.CardView
      android:id="@+id/popover"
//same..      
style="@style/popover_style"card_view:cardCornerRadius="@dimen/popup_corner_radius">
  </androidx.cardview.widget.CardView>

问题是我的scandiff工具显示对话框变得更宽了。怎么用xml替换代码会导致这种情况?

0 个答案:

没有答案