相关疑难解决方法(0)

Android对话框宽度

我似乎无法控制对话框的宽度.我有一个像这样简单的布局

<?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个字符宽.如何使对话框宽度填满屏幕?

android dialog width

50
推荐指数
5
解决办法
8万
查看次数

使对话框宽度为全屏

是的,这被问到了几种方式,但没有一种方法有效。

我正在尝试将对话框宽度扩展到全屏。

对话框布局:

<?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)

android android-alertdialog kotlin

3
推荐指数
1
解决办法
4849
查看次数

带有圆角的 Android 对话框 - 仍然显示没有圆角半径的背景

我想制作圆角对话框;但在我完成后,它看起来像这样>>

结果设计

爪哇

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)

问题是:为什么对话框仍然显示在没有圆角半径的背景中?

在寻找解决此问题的方法后,我找到了其中一些解决方案>>

1- Android 对话框 - 圆角和透明度

2-带有圆角的Android自定义警报对话框

3-带有圆角半径的Android对话框背景具有分层背景

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)

测试解决方案后的结果

结果设计

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

java android android-layout android-dialog

2
推荐指数
1
解决办法
5503
查看次数