设计布局以将按钮放置在椭圆中 Android

Design the layout to place the button in ellipse Android

我有一个设计,将按钮放置在类似于四分之一椭圆的形状中。我尝试了线性布局和相对布局。两者都不固定。我应该如何为多个屏幕(带横向的平板电脑)修复此问题。下面添加了该布局的代码..

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/mainscreen_bg"
android:layout_gravity="center_horizontal">

<!--LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="horizontal" >

<Button
    android:id="@+id/button1"
    android:layout_width="75dp"
    android:layout_height="wrap_content"
    android:text="LogIn/SignUp" /-->

<Button
    android:id="@+id/rate"
    android:layout_width="80dp"
    android:layout_height="80dp"
    android:layout_marginRight="20dp"
    android:layout_alignParentBottom="true"
    android:background="@drawable/rate" />

<Button
    android:id="@+id/vehicle"
    android:layout_width="80dp"
    android:layout_height="80dp"
    android:layout_marginRight="20dp"
    android:layout_toRightOf="@id/rate"
    android:layout_above="@id/rate"
    android:background="@drawable/vehicle" />

<Button
    android:id="@+id/hotel"
    android:layout_width="80dp"
    android:layout_height="80dp"
    android:layout_marginRight="20dp"
    android:layout_toRightOf="@id/vehicle"
    android:layout_above="@id/vehicle"
    android:background="@drawable/hotel" />

<Button
    android:id="@+id/user"
    android:layout_width="80dp"
    android:layout_height="80dp"
    android:layout_marginRight="20dp"
    android:layout_toRightOf="@id/hotel"
    android:layout_above="@id/hotel"
    android:background="@drawable/newcustomer" />

<Button
    android:id="@+id/return_vehicle"
    android:layout_width="80dp"
    android:layout_height="80dp"
    android:layout_marginRight="20dp"
    android:layout_toRightOf="@id/user"
    android:layout_above="@id/user"
    android:background="@drawable/return1" />

<Button
    android:id="@+id/sync"
    android:layout_width="80dp"
    android:layout_height="80dp"
    android:layout_marginRight="20dp"
    android:layout_toRightOf="@id/return_vehicle"
    android:layout_above="@id/return_vehicle"
    android:background="@drawable/sync" />

<Button
    android:id="@+id/report"
    android:layout_width="80dp"
    android:layout_height="80dp"
    android:layout_toRightOf="@id/sync"
    android:layout_above="@id/sync"
    android:background="@drawable/report" />

<Button
    android:id="@+id/settings"
    android:layout_width="80dp"
    android:layout_height="80dp"
    android:layout_alignParentRight="true"
    android:layout_alignParentBottom="true"
    android:background="@drawable/password_reset" />
<!-- /LinearLayout-->

</RelativeLayout>

Android 足够聪明,可以区分两个不同屏幕尺寸的相同布局文件。要为不同的屏幕尺寸定义布局,请转到布局>可用限定符>尺寸并按 >> 箭头并选择所需的屏幕 size.Inside 选择的布局,根据要求修改视图尺寸。 Note: Layout file name for small screen and large screen must be same. And Android will choose the required file at runtime

如果您需要简要说明,请阅读 this

You can also give multiple screen support by dimen.xml file

for example if you want same textsize will be appear same in all devices than you can create dimen.xml and store dimension by using

dimen.xml
<dimen name="textsize">18sp</dimen>

dimen.xml(sw600dp)
<dimen name="textsize">20sp</dimen>


dimen.xml(sw720dp)
<dimen name="textsize">22sp</dimen>


dimen.xml(sw820dp)
<dimen name="textsize">24sp</dimen>

And Apply to textview size in example.xml

 <TextView
            android:id="@+id/tv_dialog_birthdate"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textSize="@dimen/textsize" />