对话框显示 - 它不适合屏幕,我无法将对话框移动到屏幕上的其余消息
Dialog display - It not fits to the screen and I can't move dialog to the rest of the message on the screen
我有一些dialog_alert.xml
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorWhite">
<LinearLayout
android:id="@+id/cv"
android:layout_width="match_parent"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:orientation="vertical"
android:elevation="4dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorAccent"
android:gravity="center"
android:padding="15dp"
android:text="@{vm.title}"
android:textColor="@color/colorWhite"
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
<ProgressBar
style="@style/ProgresBarTop"
android:indeterminate="@{vm.working}"
android:layout_margin="0dp"
android:padding="0dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="15dp"
android:text="@{vm.message}"
android:textColor="@color/colorBlack" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<Button
style="@style/ActionButton"
android:layout_gravity="center_horizontal"
android:text="@string/ok"
android:onClick="@{v-> vm.okClick(v)}"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
并在视图模型中
AlertDialog ad = new AlertDialog(context, R.string.synchro, sb.toString()
, SYNC_COMPLETE_DIALOG);
ad.show();
当此警报与消息一起显示在屏幕上时,我无法将屏幕移动到消息的底部。它被阻止了。警报不会对触摸屏做出反应以向下移动到消息的其余部分。
有什么解决办法吗?
如果您将布局包裹在 <ScrollView>
中,您可以上下滚动对话框内容。例如,在您的 XML 中,使用如下内容:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- YOUR EXISTING LAYOUT CODE GOES HERE -->
</ScrollView>
我有一些dialog_alert.xml
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorWhite">
<LinearLayout
android:id="@+id/cv"
android:layout_width="match_parent"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:orientation="vertical"
android:elevation="4dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorAccent"
android:gravity="center"
android:padding="15dp"
android:text="@{vm.title}"
android:textColor="@color/colorWhite"
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
<ProgressBar
style="@style/ProgresBarTop"
android:indeterminate="@{vm.working}"
android:layout_margin="0dp"
android:padding="0dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="15dp"
android:text="@{vm.message}"
android:textColor="@color/colorBlack" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<Button
style="@style/ActionButton"
android:layout_gravity="center_horizontal"
android:text="@string/ok"
android:onClick="@{v-> vm.okClick(v)}"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
并在视图模型中
AlertDialog ad = new AlertDialog(context, R.string.synchro, sb.toString()
, SYNC_COMPLETE_DIALOG);
ad.show();
当此警报与消息一起显示在屏幕上时,我无法将屏幕移动到消息的底部。它被阻止了。警报不会对触摸屏做出反应以向下移动到消息的其余部分。
有什么解决办法吗?
如果您将布局包裹在 <ScrollView>
中,您可以上下滚动对话框内容。例如,在您的 XML 中,使用如下内容:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- YOUR EXISTING LAYOUT CODE GOES HERE -->
</ScrollView>