Custom Popup

4

I'm trying to make a custom popup, similar to the one in the photo, by putting a close button at the top and centering it in the middle of the screen, does anyone know how I do it? I searched for some codes, but nothing very complete

    
asked by anonymous 15.08.2014 / 01:30

1 answer

3

With DialogFragment you get that way below

mButton.setOnclickListener(new OnclickListener(){
       test();

});

public void test(){
    Dialog dialog = new Dialog(this, R.style.FullHeightDialog);
    dialog.setContentView(R.layout.seu_layout_customizado);
    dialog.show();
}

Creating XML

  • Create a root LinearLayout
  • Creates another LinearLayout with vertical orientation, where it will contain the X button, title, and description.
  • Creates a View ( <View android:layout_width="fill_parent" android:layout_height="1dp"/> ) to represent the line. To represent this grouping of icons and text (gps, wifi and wireless network) creates a RelativeLayout.
  • For the confirmation button, add in the LinearLayout root.

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="x"/>
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Melhore..."/>
    
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Para garantir..."/>
    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
        gps
        rede
        wifi
        </RelativeLayout>
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    

15.08.2014 / 21:45