我要画三个圆在我的片段,圆圈的大小不同,我指的这个链接 我所获得的结果是这样的
I need to draw three circles in my fragment ,the circles differ in size, I refer this link The result i obtained is this
这是我的XML code:更新
This is my XML Code : UPDATED
<?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:gravity="center" >
<TextView
android:id="@+id/large_volume"
android:layout_width="185dp"
android:layout_height="185dp"
android:background="@drawable/circle"
android:gravity="center"
android:text="My name is NON"
android:textColor="#FFFFFF"
android:textSize="10dp" />
<TextView
android:id="@+id/medium_volume"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_alignTop="@+id/large_volume"
android:layout_toRightOf="@+id/large_volume"
android:background="@drawable/circle"
android:gravity="center"
android:text="My name is NON"
android:textColor="#FFFFFF"
android:textSize="10dp" />
<TextView
android:id="@+id/TextView02"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_below="@+id/medium_volume"
android:layout_toRightOf="@+id/large_volume"
android:background="@drawable/circle"
android:gravity="center"
android:layout_marginTop="-3dp"
android:layout_marginLeft="-17dp"
android:text="My name is NON"
android:textColor="#FFFFFF"
android:textSize="10dp" />
</RelativeLayout>
但我需要必须是这样的
But what i need must be is like this
您可以看到圆圈必须保持并拢,但是当我使用XML的观点我不能做到这一点。我怎样才能做到这一点,我需要 onClickListeners
在我的圈子里这就是为什么我使用视图
You can see the circles must stay close together , But when i use XML view i can't achieve this . How can i achieve this , I need onClickListeners
in my circle thats why i use views
这是可以通过绘图画布实现,我听到画布无法查看所以这会限制我从给人点击听众,纠正我,如果我错了,
Is this can achieve through Canvas drawing , i heard canvas is not view so this will restrict me from giving click listeners ,Correct me if i am wrong
更新:
我满足我的需要通过XML的方式,有没有办法通过画布绘制实现这一目标,我应该张贴另一个问题为??
I fulfill my need through XML approach ,is there any way to achieve this through canvas drawing ,Should i post another question for that ??
推荐答案
酪氨酸这种
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/num_txt"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginTop="0dp"
android:background="@drawable/bg_red"
android:gravity="center"
android:text="My name is NON"
android:textColor="#FFFFFF"
android:textSize="10dp" />
</RelativeLayout>
</RelativeLayout>
保存drwable bg_red.xml
save in drwable 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>
编辑code -----
Edited Code -----
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<TextView
android:id="@+id/num_txt"
android:layout_width="185dp"
android:layout_height="185dp"
android:layout_alignParentTop="true"
android:layout_marginTop="163dp"
android:background="@drawable/bg_red"
android:gravity="center"
android:text="My name is NON"
android:textColor="#FFFFFF"
android:layout_marginLeft="10dp"
android:textSize="10dp" />
<TextView
android:id="@+id/TextView02"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/TextView01"
android:layout_marginRight="90dp"
android:layout_marginTop="122dp"
android:background="@drawable/bg_red"
android:gravity="center"
android:text="My name is NON"
android:textColor="#FFFFFF"
android:textSize="10dp" />
<TextView
android:id="@+id/TextView01"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_alignTop="@+id/num_txt"
android:layout_toRightOf="@+id/num_txt"
android:background="@drawable/bg_red"
android:gravity="center"
android:text="My name is NON"
android:textColor="#FFFFFF"
android:textSize="10dp" />
</RelativeLayout>
相关推荐
最新文章