如何使ConstraintLayout填充BottomSheetDialogFragment中的可见空间?

时间:2018-04-20 06:17:43

标签: android android-constraintlayout

我正在使用BottomSheetDialogFragment内部的相机取景器。这个片段开始填满屏幕。我正在使用约束布局,将按钮水平放置在按钮上,问题是在纸张对话框未完全展开时无法看到快门按钮。我想知道是否有办法让底部的快门按钮显示达到峰值,然后当工作表对话框扩大时,快门会移到底部?

如果我没有详细解释或想了解更多细节,请告诉我。

这是XML布局:

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/photo_creator"
    android:layout_width="match_parent"
    android:layout_height="460dp">

    <TextureView
        android:id="@+id/photo_view_finder"
        android:layout_width="330dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <ImageView
        android:id="@+id/photo_flash"
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:layout_margin="8dp"
        android:contentDescription="@string/content_description"
        android:src="@drawable/ic_flash_off"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="@+id/photo_view_finder" />

    <ImageView
        android:id="@+id/photo_shutter"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:contentDescription="@string/content_description"
        android:onClick="takePhoto"
        android:src="@drawable/background_photo"
        app:layout_constraintBottom_toBottomOf="@+id/photo_view_finder"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias=".96" />

    <ImageView
        android:id="@+id/photo_switch"
        android:layout_width="36dp"
        android:layout_height="0dp"
        android:layout_marginStart="16dp"
        android:contentDescription="@string/content_description"
        android:onClick="switchCamera"
        android:src="@drawable/ic_camera_front"
        app:layout_constraintBottom_toBottomOf="@+id/photo_shutter"
        app:layout_constraintDimensionRatio="H,10:9"
        app:layout_constraintLeft_toRightOf="@+id/photo_shutter"
        app:layout_constraintTop_toTopOf="@+id/photo_shutter" />

</android.support.constraint.ConstraintLayout>

0 个答案:

没有答案