Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android alert dialog not styled properly on Lollipop

I have tried everything to get this working and cannot figure it out.

I am trying to use an alert dialog im my app. It works fine on KitKat but not on Lollipop.

I have even tried using many material dialogs on GitHub and again they work on Kitkat but not on Lollipop.

I am testing on my Nexus 5 with stock nexus factory image.

KITKAT WITH GITHUB MATERIAL DIALOG

enter image description here

KITKAT WITH STOCK ALERT DIALOG

enter image description here

LOLLIPOP WITH GITHUB MATERIAL DIALOG

enter image description here

LOLLIPOP WITH STOCK ALERT DIALOG

enter image description here

Also this is the library on github installed on the same device its not working on. So its something about my app that is causing this. what could it be

enter image description here

like image 821
BigDX Avatar asked Oct 28 '14 02:10

BigDX


2 Answers

android:fitsSystemWindows="true" was the culprit.

I had that declared in my styles.xml.

Removed it from styles.xml and placed in my layout and it working now.

like image 192
BigDX Avatar answered Oct 16 '22 16:10

BigDX


I had the same problem and didn't find any fitsSystemWindows on any of my styles.xml.

To solve it i had to wrap the Layout in a FrameLayout and add the margins to the Layout like this:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="@dimen/dialog_margin_title"
        android:layout_marginBottom="@dimen/dialog_margin"
        android:layout_marginLeft="@dimen/dialog_margin"
        android:layout_marginStart="@dimen/dialog_margin"
        android:layout_marginRight="@dimen/dialog_margin"
        android:layout_marginEnd="@dimen/dialog_margin"
        android:orientation="vertical">

        <TextView
            android:id="@+id/textView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Please enter the email address of the person you would like to follow, this person will be notified." />

        <EditText
            android:id="@+id/editText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="10"
            android:inputType="textEmailAddress" />
    </LinearLayout>
</FrameLayout>
like image 37
Carlos Jimenez Avatar answered Oct 16 '22 16:10

Carlos Jimenez