Support phone and tablet for the interval between buttons on the layout

I have the following layouts in my android project. Because I want to support the view for different devices and tabs for Android.

layout-large layout-normal layout-small layout-xlarge 

In the Gradle app, it has been installed since min. 9-22.

When I test on 5-inch phones, 7-inch tablets, and phones smaller than 5 inches, I see a 5-inch phone and a 7-inch tablet, it always uses a β€œbig layout”, so there are 2 buttons located in the center of the screen horizontally does not give the correct distance in the tablet; it shows at the correct interval in the 5-inch phone, as expected. Could you advise me how to take care of the layout of the buttons in order to support a 5-inch phone and a 7-inch layout with a single layout. Looking back, there are so many suggestions and a lot to get confused ... When I looked at the link to the android, the link of the Android developer could not understand much.

layout large.xml

  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MyActivity" android:background="@drawable/bg"> <Button android:layout_width="70px" android:layout_height="70px" android:id="@+id/PlayPauseButton" android:onClick="doClick" android:layout_marginLeft="81dp" android:layout_marginStart="81dp" android:layout_marginBottom="169dp" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" /> <Button android:layout_width="70px" android:layout_height="70px" android:id="@+id/StopButton" android:onClick="stopAudio" android:layout_alignTop="@+id/PlayPauseButton" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" android:layout_marginRight="102dp" android:layout_marginEnd="102dp" /> </RelativeLayout> 

UPDATED:

I ask my question even more simple. I have a 3.2-inch phone, 4.2-inch phone, 4.3-inch phone, 4.5-inch phone, 5-inch phone and one 7-inch tablet / I want to support my application in all these devices . I set min 9 max 22 to gradle. What should I do now to create the "layout" and "drawable" folders? I am embarrassed to see links in android and other forum links. I have a Relative Layout in all layouts and it is set with match_parent width and height. Should I even set the static width and height here? - Stella right now

+8
android
source share
3 answers

For different layouts for different screen sizes, try calling the layout folder something like layout-sw600dp instead of layout-large .

Could you advise me how to take care of the layout of the buttons in order to support a 5-inch phone and a 7-inch layout with a single layout.

Try declaring a dimension ( <dimen name="dimenName">30dp</dimen> ) in both values/dimens.xml and values-sw600dp/dimens.xml with the appropriate values ​​and access them with @dimen/dimenName in your layout.

If you need more help, post some screenshots. You should also try using dp units instead of px .

0
source share

According to the Platform Version, only 6.8% of devices are below API 4.0.3 and in accordance with "Screen Size and Density". Only 4.4% have smaller screens than usual.

  • So, you can DELETE the layout-small folder and make your minSdkVersion as 14 .
  • Now you can start using the new size group to create layouts, i.e. sw<N>dp .

As indicated here

The reason designing for 7-inch tablets is a difficult task when using generic size groups is because the 7-inch tablet is technically in the same group as the 5-inch handset (large group). Although these two devices seem close to each other in size, the amount of space for the user interface of the application is significantly different, as is the style of user interaction.

You need to define different layouts for 5-inch and 7-inch devices, so you have to make a 7 " layout-sw600dp in the layout-sw600dp and leave everything in the layout folder (unless you make layout-sw720dp for 10 inches of tablet).

If you still need a layout for 5-inch devices and 5 devices, try layout-large for 5 "devices and just layout for <5" .

0
source share

You need to make the folder just for drawing, and then put the whole image in it. This is a shared folder for all types. Then you can take your button in the relative layout and set the center button in the center horizontally = true, as well as set the height and width with the fill parent and set the left and right margins to 20dp to set in the center.

0
source share

All Articles