我似乎无法控制对话框的宽度.我有一个像这样简单的布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:theme="@android:style/Theme.Dialog">
<ScrollView
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/name_prompt_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/name_prompt"
android:padding="10dip"/>
<EditText
android:id="@+id/name_inp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:lines="1"
android:maxLines="1"
android:maxLength="48"
android:inputType="text" />
<TextView
android:id="@+id/t1_prompt_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/t1_prompt"
android:padding="10dip"/>
<Spinner
android:id="@+id/t1_inp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:lines="1"
android:maxLines="1"
android:maxLength="48"
android:inputType="text"
android:singleLine="true"
android:layout_weight="1"
android:entries= "@array/t1_allowed_values" />
</LinearLayout>
</ScrollView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
由于某种原因,对话框只有足够宽的文本输入字段大约11个字符宽.如何使对话框宽度填满屏幕?
是的,这被问到了几种方式,但没有一种方法有效。
我正在尝试将对话框宽度扩展到全屏。
对话框布局:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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:id="@+id/constraint_layout"
android:layout_width="match_parent"
android:layout_height="300dp">
<android.support.constraint.Guideline
android:id="@+id/guideline3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.08" />
<TextView
android:fontFamily="@font/gotham_medium_regular"
android:textAllCaps="true"
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Login"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Large"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="@+id/guideline3"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:fontFamily="@font/gotham_light"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
android:layout_marginTop="8dp"
app:layout_constraintStart_toStartOf="@+id/guideline3"
app:layout_constraintTop_toBottomOf="@+id/textView6"
android:id="@+id/textView7"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Enter your phone number to proceed" />
<android.support.design.widget.TextInputLayout
android:id="@+id/text_input"
android:layout_marginTop="24dp"
android:layout_width="0dp"
app:layout_constraintTop_toBottomOf="@+id/textView7"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="@+id/guideline4"
app:layout_constraintStart_toStartOf="@+id/guideline3">
<android.support.design.widget.TextInputEditText
android:id="@+id/userPhone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/gotham_light"
android:hint="PHONE NUMBER"
android:inputType="phone"
android:text="+91" />
</android.support.design.widget.TextInputLayout>
<android.support.constraint.Guideline
android:id="@+id/guideline4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.92" />
<Button
android:layout_marginBottom="@dimen/activity_horizontal_margin"
android:id="@+id/continueButton"
android:layout_width="0dp"
android:layout_height="wrap_content" …Run Code Online (Sandbox Code Playgroud) 我想制作圆角对话框;但在我完成后,它看起来像这样>>

爪哇
AlertDialog.Builder dialogBuilder= new AlertDialog.Builder(this);
dialogBuilder.setView(R.layout.complain_dialog);
final AlertDialog alertDialog= dialogBuilder.create();
alertDialog.show();
Run Code Online (Sandbox Code Playgroud)
XML
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="100dp"
app:cardBackgroundColor="#FFF"
app:cardCornerRadius="15dp">
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginBottom="15dp"
android:background="@color/black_overlay" />
</android.support.v7.widget.CardView>
Run Code Online (Sandbox Code Playgroud)
问题是:为什么对话框仍然显示在没有圆角半径的背景中?
在寻找解决此问题的方法后,我找到了其中一些解决方案>>
Java-经过上述解决方案的测试
Dialog dialog= new Dialog(getContext());
dialog.setContentView(R.layout.complain_dialog);
dialog.getWindow().setBackgroundDrawable(new
ColorDrawable(Color.TRANSPARENT));
dialog.show();
Run Code Online (Sandbox Code Playgroud)
测试解决方案后的结果

现在对话框根本没有出现!任何人都可以给我解决这个问题吗?先感谢您。