布局与圆圈中的按钮?

Vik*_*ngh 3 layout android relativelayout android-layout android-linearlayout

这对所有人来说都是一个挑战..我们如何将按钮设置为相对或线性布局或任何其他布局在圆圈中,与此图像相同.我们可以使用xml或使用代码来完成.请帮忙.

提前致谢

cdh*_*ker 9

此方法的布局相当于绘制任意X和Y坐标.

特征:

  • 无论您将子对象用作顶级布局还是将其嵌入到另一个布局中,子对象都会自动居中于RelativeLayout.
  • 对于N个图像,您的布局仅包含N + 1个视图.

此示例布局显示如何将ImageView放置在XY网格的每个象限中,原点位于中心:

eclipse截图

<?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>
Run Code Online (Sandbox Code Playgroud)