-2

I want to set the width and height of dialog fragment. Have seen many examples but they do it in Java file. I want do it in xml file without hardcoding the values. How can I achieve this?

1 Answers1

0

Without hardcoding this might be the solution, If the fragment is in a linear layout then this is enough

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    ... />
oldcode
  • 1,669
  • 3
  • 22
  • 41
  • I dont want it full screen...I want to set it to my custom height and width – Maria Anasthesia Aug 19 '16 at 11:39
  • custom means you set the width and height so set width and height as desired with `dp` values. – oldcode Aug 19 '16 at 11:39
  • But Idont want to hardcore it... Can i do something with margin values? – Maria Anasthesia Aug 19 '16 at 11:44
  • Margin and padding will affect from the height and width. What exact height spec do you want ? – oldcode Aug 19 '16 at 11:46
  • The height of the dialog fragment... I have 1 more doubt... Currently in the dialog fragment I have an edit text. When I click on it, I want the fragment to resize itself instead of going up the screen – Maria Anasthesia Aug 19 '16 at 11:48
  • You mean when someone clicks the edidtext you want to resize the dialog fragment ? – oldcode Aug 19 '16 at 11:50
  • Yes currently I have a dialog fragment as per the image in the question http://stackoverflow.com/questions/26974068/how-to-set-the-width-of-a-dialogfragment-in-percentage . Instead of button "Los", I have an edit text and my dialog fragment height is still more. When I click on edit text, the key board pops up and my entire top part of dialog fragment moves up. I need to prevent this – Maria Anasthesia Aug 19 '16 at 11:52