-1

I am facing a weird issue with dialog fragment , its not showing the complete proper layout. I have checked on Moto G and Nexus 5 both show same result. Any help would be appreciated.

Graphical layout screen shot is:

enter image description here

Device screen shot is:

enter image description here

Here is the activity code:

public class MainActivity extends FragmentActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    showGridTutorial();

}

public void showGridTutorial() {

    DialogFragment fragment = new GridTutorial();
    fragment.show(getSupportFragmentManager(), "grid_tutorial");
}

public static class GridTutorial extends DialogFragment {

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        Dialog dialog = new Dialog(getActivity());
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.dialog_layout);

        return dialog;
    }

}

}    

XML layout file:

<?xml version="1.0" encoding="utf-8"?>

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

xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#eeede9"
>

<View
    android:id="@+id/vertical"
    android:layout_width="1dp"
    android:layout_height="fill_parent"
    android:layout_centerHorizontal="true"
    android:layout_above="@+id/btnGotIt"
    android:background="#e8e7e4" 
    />

<View
    android:id="@+id/horizontal"
    android:layout_width="fill_parent"
    android:layout_height="1dp"
    android:layout_centerVertical="true"
    android:background="#e8e7e4" />



<Button
    android:id="@+id/btnGotIt"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="48dp"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:text="Got it" 
    android:gravity="center"
    android:background="@android:color/black"
    android:textColor="#eeede9"
    android:textAppearance="?android:attr/textAppearanceLarge"
  />

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_toLeftOf="@+id/vertical"
    android:layout_above="@+id/horizontal"
    android:src="@drawable/showease3" />

 <ImageView
    android:id="@+id/imageView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:layout_toRightOf="@+id/vertical"
    android:layout_above="@+id/horizontal"
    android:src="@drawable/showdase" />

  <ImageView
    android:id="@+id/imageView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/horizontal"
    android:layout_toLeftOf="@+id/vertical"
    android:layout_above="@+id/btnGotIt"
    android:src="@drawable/showcase" />


     <ImageView
    android:id="@+id/imageView4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_below="@+id/horizontal"
    android:layout_toRightOf="@+id/vertical"
    android:layout_above="@+id/btnGotIt"
    android:src="@drawable/showdase" />


</RelativeLayout>
Ravi
  • 4,872
  • 8
  • 35
  • 46

2 Answers2

1

Try to change RelativeLayout width and height to wrap_content.

xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#eeede9"

Hope this will help you!

ArbenMaloku
  • 548
  • 4
  • 15
  • It didnt work , instead the graphical layout also started showing screen similar to device screenshot – Ravi Sep 09 '14 at 12:55
0

You need to choose a minimum width and minimum height for your layout. Something like :

android:minWidth="600dp" android:minHeight="800dp"

Just try playing with the right values.

Joseph
  • 5,793
  • 4
  • 34
  • 41