Full Width Dialog on Bottom of Screen - Android

Viewed 1327

enter image description here

I have to create the similar UX on some event. This is the UX of Any.Do android app.

I tried to achieve this by specifying my activity theme as Theme.AppCompat.Light.Dialog and setting Window Layout Params gravity to Bottom.

But I am getting this :

enter image description here

The Dialog is not drawing of full width. I tried to alter following properties of Theme.AppCompat.Light.Dialog :

<item name="android:windowMinWidthMajor">100%</item>
<item name="android:windowMinWidthMinor">100%</item>

Then I get this :

enter image description here

When I increase any of Minor or Major width properties, The Dialog appears as following:

enter image description here

My Manifest:

<activity android:name=".ScreenRateReminder"
          android:theme="@style/CustomDialog"/>

Style Definition:

<style name="CustomDialog" parent="Theme.AppCompat.Light.Dialog">
        <item name="android:windowMinWidthMajor">100%</item>
        <item name="android:windowMinWidthMinor">100%</item>
</style>

Layout Code:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <RelativeLayout
            android:id="@+id/company_info_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingTop="10dp"
            android:paddingBottom="10dp"
            android:paddingLeft="20dp"
            android:paddingRight="20dp">

            <de.hdodenhof.circleimageview.CircleImageView
                android:id="@+id/logo"
                android:layout_width="100dp"
                android:layout_height="100dp"
                android:src="@drawable/building_image"/>

            <LinearLayout

                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:layout_toRightOf="@+id/logo"
                android:layout_marginTop="20dp"
                android:paddingLeft="10dp"
                android:paddingRight="10dp"
                android:layout_centerVertical="true">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Title"/>

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Tagline"/>
            </LinearLayout>
        </RelativeLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="30dp"
            android:gravity="center"
            android:orientation="horizontal">


                <ImageView
                    android:id="@+id/btn_satisfied"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/ic_smile" />

                <ImageView
                    android:id="@+id/btn_happy"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/ic_average"
                    android:layout_marginLeft="20dp"/>

                <ImageView
                    android:id="@+id/angry_button"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/ic_angry"
                    android:layout_marginLeft="20dp"/>

        </LinearLayout>
    </LinearLayout>

</RelativeLayout>

Activity Code:

public class RateReminderActivity extends Activity{

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Window window = getWindow();
        WindowManager.LayoutParams layoutParams =  window.getAttributes();
        layoutParams .gravity = Gravity.BOTTOM;

        window.setAttributes(layoutParams);

        requestWindowFeature(Window.FEATURE_NO_TITLE);

        setContentView(R.layout.screen_rate_reminder);

}

I even tried by : window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT);

and :

wlp.width = WindowManager.LayoutParams.MATCH_PARENT;
wlp.height = WindowManager.LayoutParams.WRAP_CONTENT;

But for me nothing is making the dialog as full width.

1 Answers
Related