Java NestedScrollView没有';无法在AlertDialog中显示
我有一个具有自定义视图的AlertDialog,视图如下:Java NestedScrollView没有';无法在AlertDialog中显示,java,android,Java,Android,我有一个具有自定义视图的AlertDialog,视图如下: <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
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">
<androidx.appcompat.widget.Toolbar
android:background="@color/grey_1"
android:id="@+id/edit_point_toolbar"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/edit_scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/edit_point_close"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:src="@drawable/ic_close_red_32dp"
android:layout_margin="4dp"
android:clickable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
app:layout_constraintRight_toLeftOf="@id/edit_point_close"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:text="Edit point"
android:textColor="@color/black"
android:textSize="15dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.appcompat.widget.Toolbar>
<androidx.core.widget.NestedScrollView
android:id="@+id/edit_scrollView"
app:layout_constraintTop_toBottomOf="@id/edit_point_toolbar"
android:layout_width="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_height="0dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp">
<EditText
android:id="@+id/edit_point_name"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintBottom_toTopOf="@id/save_edit_point"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:minLines="3"
android:textDirection="rtl"
android:background="@drawable/new_book_text_box"
android:gravity="right|top"
android:textAlignment="gravity"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<Button
app:layout_constraintTop_toBottomOf="@id/edit_point_name"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:id="@+id/save_edit_point"
android:layout_width="0dp"
app:layout_constraintWidth_percent="0.7"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp"
android:backgroundTint="@color/green_500"
android:text="Confirm"
android:textColor="#FFF" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
我不明白为什么嵌套的滚动视图没有显示。事实上,当我设置高度wrap_content而不是0dp时,它会显示,但滚动不好,并且与工具栏重叠。
有人能找出我错在哪里吗?我尝试了几种方法并
<androidx.core.widget.NestedScrollView
android:id="@+id/edit_scrollView"
app:layout_constraintTop_toBottomOf="@id/edit_point_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constrainedHeight="true"
app:layout_constraintBottom_toBottomOf="parent">
我认为这将给你想要的设计,但老实说,我不太明白为什么它的工作和0dp不。对我来说最奇怪的是,0dp在正常布局中膨胀视图时有效,但在AlertDialog中膨胀视图时无效。我尝试了几种方法并
<androidx.core.widget.NestedScrollView
android:id="@+id/edit_scrollView"
app:layout_constraintTop_toBottomOf="@id/edit_point_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constrainedHeight="true"
app:layout_constraintBottom_toBottomOf="parent">
我认为这将给你想要的设计,但老实说,我不太明白为什么它的工作和0dp不。对我来说最奇怪的是,0dp在正常布局中膨胀视图时有效,但在AlertDialog中膨胀视图时无效。谢谢,这是有效的!对,我也是。0dp适用于除AlertDialog之外的所有布局!app:layout_constrainedHeight=“true”已生效。谢谢谢谢你,这很有效!对,我也是。0dp适用于除AlertDialog之外的所有布局!app:layout_constrainedHeight=“true”已生效。非常感谢。