这是个挑战...
我们如何将按钮放在相对布局、线性布局或任何其他布局中,使它们像这张图片一样呈圆形。我们可以使用xml或代码来实现。请帮忙。
提前致谢。
这种方法相当于绘制任意X和Y坐标的布局。
特点:
此示例布局显示了如何在以中心为原点的XY网格的每个象限中放置一个ImageView:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="@+id/center"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_centerInParent="true"
android:background="#FFFF0000"
/>
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:background="#FF00FF00"
android:layout_above="@id/center"
android:layout_toLeftOf="@id/center"
android:layout_marginRight="100dp"
android:layout_marginBottom="25dp"
/>
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:background="#FF00FF00"
android:layout_below="@id/center"
android:layout_toLeftOf="@id/center"
android:layout_marginRight="100dp"
android:layout_marginTop="25dp"
/>
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:background="#FF00FF00"
android:layout_above="@id/center"
android:layout_toRightOf="@id/center"
android:layout_marginLeft="100dp"
android:layout_marginBottom="25dp"
/>
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:background="#FF00FF00"
android:layout_below="@id/center"
android:layout_toRightOf="@id/center"
android:layout_marginLeft="100dp"
android:layout_marginTop="25dp"
/>
</RelativeLayout>
我认为这只能使用不同于AbsoluteLayout的布局来完成。具体该如何操作,你需要自己尝试,因为它有一点棘手,但是可以实现!
这就是我所想的,顺便说一下,虽然不确定是否100%正确,但只要付出一些努力,您就可以将其设置为成比例的 - 以传递不同的分辨率。