答案 0 :(得分:0)
在xml布局中;
<?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">
<TextView
android:id="@+id/circle1"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentTop="true"
android:layout_marginTop="150dp"
android:background="@drawable/bg_red"
android:gravity="center"
android:text="Left circle"
android:textColor="#FFFFFF"
android:layout_marginLeft="10dp"
android:textSize="20dp" />
<TextView
android:id="@+id/circle2"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignTop="@+id/circle1"
android:layout_toRightOf="@+id/circle1"
android:background="@drawable/bg_red"
android:gravity="center"
android:text="Middle circle"
android:textColor="#FFFFFF"
android:textSize="20dp" />
<TextView
android:id="@+id/circle3"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignTop="@+id/circle2"
android:layout_toRightOf="@+id/circle2"
android:background="@drawable/bg_red"
android:gravity="center"
android:text="Right circle"
android:textColor="#FFFFFF"
android:textSize="20dp" />
</RelativeLayout>
在你的drawable中,插入像这样的bg_red.xml来制作红色圆圈;
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<corners android:radius="10dip"/>
<stroke android:color="#FF0000" android:width="5dip"/>
<solid android:color="#FF0000"/>
</shape>