T
T
TimkaTV2015-07-31 13:32:26
Android
TimkaTV, 2015-07-31 13:32:26

How to correctly set the custom markup of the dialog?

Good afternoon,
Created a window

AlertDialog.Builder adb = new AlertDialog.Builder(cont, R.style.MyAlertDialogTheme);
View v = LayoutInflater.from(cont).inflate(R.layout.download_layout, null);
adb.setView(v);

Style
<style name="MyAlertDialogTheme">
        <item name="android:windowBackground">@color/null_c</item>
    </style>

The markup itself
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="#00000000">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="200dp"
    android:gravity="center"
    android:background="@drawable/download_bg"
    android:layout_alignParentBottom="true"
    android:layout_alignParentTop="false">
    <Button
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Скачать"
        android:id="@+id/load"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:layout_marginLeft="3dp"
        android:layout_marginRight="3dp"
        android:layout_marginBottom="2dp"
        android:textColor="#000000" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:text="Прикрепленный файл"
        android:id="@+id/title"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:textColor="@color/white"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:textSize="20dp"
        android:layout_marginLeft="8dp"
        android:layout_marginTop="10dp" />

    <View
        android:layout_width="wrap_content"
        android:layout_height="1dp"
        android:layout_below="@+id/title"
        android:layout_marginTop="10dp"
        android:background="@color/space_bg_drawer"
        android:id="@+id/view" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="50dp"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="txt"
        android:id="@+id/txt"
        android:layout_below="@+id/view"
        android:layout_alignLeft="@+id/title"
        android:layout_alignStart="@+id/title"
        android:layout_marginTop="6dp"
        android:textSize="16dp"
        android:textColor="@color/white"
        android:layout_above="@+id/load"
        android:layout_alignRight="@+id/load"
        android:layout_alignEnd="@+id/load" />
</RelativeLayout>
</RelativeLayout>

Now the question is how to center the window and remove the white background
e79a042cda724ca28bf614237027538b.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
U
Urenev Konstantin, 2017-03-19
@ureneva1999

You can add this tag in the style:
<item name="android:gravity">center</item>, maybe it will work. Another option is to inherit the style from some standard one. For example : parent="android:Theme.Dialog

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question