Android Constraintlayout(在RelativeLayout中)布局\u alignParentBottom从底部剪切(在应用程序的默认模式下)
我在RelativeLayout中添加了ConstraintLayout,我希望它位于RelativeLayout的底部。因此,当应用程序以全屏模式打开,但在默认模式下,constraint layout从底部剪切时,这是合适的 我在不同的场景中检查过这个东西,比如如果我把它放在顶部,即使在默认模式下也会正常,但是当我将它与底部对齐时,它会被剪切Android Constraintlayout(在RelativeLayout中)布局\u alignParentBottom从底部剪切(在应用程序的默认模式下),android,android-layout,android-constraintlayout,android-relativelayout,Android,Android Layout,Android Constraintlayout,Android Relativelayout,我在RelativeLayout中添加了ConstraintLayout,我希望它位于RelativeLayout的底部。因此,当应用程序以全屏模式打开,但在默认模式下,constraint layout从底部剪切时,这是合适的 我在不同的场景中检查过这个东西,比如如果我把它放在顶部,即使在默认模式下也会正常,但是当我将它与底部对齐时,它会被剪切 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/androi
<RelativeLayout 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="match_parent"
android:layout_height="match_parent"
tools:context="org.cocos2dx.cpp.AppActivity"
android:id="@+id/cameraView">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/control"
android:layout_width="match_parent"
android:layout_height="112dp"
android:paddingBottom="0dp"
android:layout_alignParentBottom="true"
android:background="@color/control_background">
<ImageButton
android:id="@+id/cancelBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="30dp"
android:layout_marginLeft="30dp"
android:background="@android:color/transparent"
android:src="@drawable/close"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="@+id/imageCaptureBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@android:color/transparent"
android:scaleX="1.20"
android:scaleY="1.20"
android:src="@drawable/capture"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.5" />
<ImageButton
android:id="@+id/reverseCameraBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|right"
android:layout_marginEnd="30dp"
android:layout_marginRight="30dp"
android:background="@android:color/transparent"
android:src="@drawable/reverse_cam"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.508" />
</androidx.constraintlayout.widget.ConstraintLayout>
</RelativeLayout>
但当我把它交给android:layout_alignParentBottom=“true”时,它只会在应用程序的默认模式下被剪切,我希望这个constraintLayout位于RelativeLayout的底部
您也可以使用约束布局作为根视图,如下所示
<?xml version="1.0" encoding="utf-8"?>
<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="match_parent"
android:layout_height="match_parent"
android:id="@+id/cameraView">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/control"
android:layout_width="match_parent"
android:layout_height="112dp"
android:layout_alignParentBottom="true"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:background="@color/colorPrimary">
<ImageButton
android:id="@+id/cancelBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="30dp"
android:layout_marginLeft="30dp"
android:background="@android:color/transparent"
android:src="@drawable/ic_attach"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="@+id/imageCaptureBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@android:color/transparent"
android:scaleX="1.20"
android:scaleY="1.20"
android:src="@drawable/ic_attach"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<ImageButton
android:id="@+id/reverseCameraBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|right"
android:layout_marginEnd="30dp"
android:layout_marginRight="30dp"
android:background="@android:color/transparent"
android:src="@drawable/ic_attach"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="RtlHardcoded" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
为什么要将rootlayout用作relativelayout?尝试在relativelayout
中设置为fillViewPort
true,通过将fillViewPort设置为true也不起作用,它仍然提供相同的输出。仅供参考:我已经在Xiomi Redmi 5上进行了测试。注意:它在全屏模式下工作正常,但当我切换到默认模式时,它会给我奇怪的输出