0

I am developing an android app where i have 40 xml layouts.

Previous projects i was using multiple folders to support multiple screen but now i have 40 layouts its difficult to create different folder.

i heard about dimensions but i don't know how to achieve that .can any one provide some code or example

Thank you

Before asking this question i read following answer but it is asked in 2013.

Different resolution support android

Community
  • 1
  • 1
scott
  • 3,112
  • 19
  • 52
  • 90
  • The answer you' re referring to is still at least 98% valid. So start working with what you have there (including, yes, the link to the official documentation :) ). If you manage to understand the philosophy behind the system of handling different screen sizes once, you will easily implement future changes. – Bö macht Blau Aug 21 '15 at 06:05
  • @ 0X0nosugar.thank you for the clarification.suppose i have 10 buttons and some textview in one layout then is it i need to set dimensions for all buttons and textview ? – scott Aug 21 '15 at 06:07

1 Answers1

1

If you have ten Buttons and one TextView in your layout, then the first thing to do would be to put the values (in dp) for the UI Elements in the 'res/values/dimens.xml' file, for example:

    <dimen name="btn_width">64dp</dimen>

To support different screen sizes or orientation changes, you might want to have alternative values. These would go into the respective 'values-.../dimen.xml' file.

In the layout xml file, you could write:

 <Button
    android:layout_width="@dimen/btn_width"
    android:layout_height="@dimen/btn_height"
    android:text="New Button"
    android:id="@+id/button"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"/>
Bö macht Blau
  • 12,820
  • 5
  • 40
  • 61