问题
I am testing the Android application in a small screen mobile. If I use Samsung tablets like other landscape mobile to test my android application the contents are moved slightly. How do I solve the screen resolution in Android?
回答1:
I think you should better check it in the Developer's website, where you have all the information. Here it is Supporting Multiple Screens In Android
回答2:
use this in manifest.xml
<supports-screens
android:resizeable="true"
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:anyDensity="true"/>
回答3:
you can create multiple layouts as per screen size (four different screen size) & put them in different folders under res like below
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
Also you need to add below lines in menifest file
<supports-screens
android:resizeable="true"
android:smallScreens="false"
android:normalScreens="true"
android:largeScreens="true"
android:anyDensity="true"/>
For more information check this link
回答4:
Try not to hardcode things in terms of px. Try using fill_parent wrap_content. Under very necessary circumstances,create separate folders for your layout as in layout,layout-land,layout-small,layout-small-land,layout-large etc. Place your layout in these folders and change your layout settings. Rest will be taken care by Android OS.
回答5:
I think you shuold get the screen resoloution in using java code and then set the widgets size by dynamically in oncreate()
method of activity
by using the given resolution.
来源:https://stackoverflow.com/questions/9029170/how-to-solve-android-screen-size-for-different-mobile-devices