问题
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
回答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"/>
来源:https://stackoverflow.com/questions/32133266/how-to-support-different-screen-size-in-android-using-dimensions