Как увеличить ширину диалога пользовательских предупреждений? - PullRequest
0 голосов
/ 03 июля 2018

На самом деле у меня есть собственное AlertDialog в моем приложении, но я реализовал в нем SegmentButton , который не подходит должным образом в AlertDialog, как вы можете видеть на экране ниже.

Очевидно, что я бы предпочел изменить размеры и подогнать элементы только с помощью кнопки SegmentButton, если это возможно, но если нет, то в любом случае было бы здорово увеличить весь AlertDialog

enter image description here

Так что я бы знал, возможно ли сделать этот диалог больше по ширине.

Вот мой XML-код для пользовательского AlertDialog

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"


    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"

    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"

    android:gravity="center"

    android:focusableInTouchMode="true"

    android:background="#20d2d2d2"

    android:orientation="vertical">


    <TextView

        android:id="@+id/deskART"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:layout_gravity="center"

        android:layout_marginBottom="5dp"

        android:layout_marginTop="5dp"

        android:text="VARIANTI"

        android:textAlignment="center"
        android:textColor="#008b58"
        android:textSize="20sp"
        android:textStyle="bold"
        tools:ignore="HardcodedText" />


    <SearchView
        android:id="@+id/searchMenu"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:iconifiedByDefault="false" />



    <LinearLayout
        android:id="@+id/TitleBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">



        <TextView
            android:id="@+id/desc"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginBottom="2dp"
            android:layout_marginEnd="2dp"
            android:layout_marginLeft="2dp"
            android:layout_marginRight="2dp"
            android:layout_marginStart="2dp"
            android:layout_marginTop="2dp"
            android:layout_weight="2"
            android:text="Descrizione"
            tools:ignore="HardcodedText" />

        <TextView
            android:paddingEnd="10dp"
            android:id="@+id/preMeno"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_margin="2dp"
            android:layout_weight="1"
            android:text="+    -"
            android:textAlignment="textEnd"
            tools:ignore="HardcodedText,RtlSymmetry" />

    </LinearLayout>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerViewVarianti"
        android:layout_width="match_parent"
        android:layout_height="400dp"
        android:layout_marginTop="5dp"
        android:isScrollContainer="false"
        android:scrollbars="vertical" />



    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:orientation="horizontal"
        tools:ignore="UselessParent">

        <co.ceryle.segmentedbutton.SegmentedButtonGroup
            android:id="@+id/segmentedButtonGroup"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_gravity="center_horizontal"
            android:elevation="2dp"
            app:sbg_backgroundColor="@color/green"
            app:sbg_dividerColor="@color/white"
            app:sbg_animateSelectorDuration="400"
            app:sbg_dividerPadding="8dp"
            app:sbg_dividerRadius="2dp"
            app:sbg_dividerSize="2dp"
            app:sbg_position="0"
            app:sbg_radius="1dp"
            app:sbg_rippleColor="@color/green"
            app:sbg_selectorColor="@color/orange">

            <co.ceryle.segmentedbutton.SegmentedButton
                android:layout_width="0dp"
                android:layout_height="50dp"
                android:layout_weight="1"
                app:sb_drawable="@drawable/convar"/>

            <co.ceryle.segmentedbutton.SegmentedButton
                android:layout_width="0dp"
                android:layout_height="50dp"
                android:layout_weight="1"
                app:sb_drawable="@drawable/piu"/>

            <co.ceryle.segmentedbutton.SegmentedButton
                android:layout_width="0dp"
                android:layout_height="50dp"
                android:layout_weight="1"
                app:sb_drawable="@drawable/meno"/>

            <co.ceryle.segmentedbutton.SegmentedButton
                android:layout_width="0dp"
                android:layout_height="50dp"
                android:layout_weight="1"
                app:sb_drawable="@drawable/senza"/>

        </co.ceryle.segmentedbutton.SegmentedButtonGroup>

    </LinearLayout>



</LinearLayout>

1 Ответ

0 голосов
/ 04 июля 2018

Решено добавлением следующего кода ниже моего метода AlertDialog

 dialog.getWindow().setBackgroundDrawableResource(R.color.semitransparent);

Ikk почему, но это решило мою проблему, увеличив AlertDialog

...