我想画的东西是这样的:垂直地画彩条 - 安卓
鉴于条数是动态的,它必须是圆形
我试图把里面的LinearLayout意见水平方向重量和=视图数量(或圆圈内的彩条数量)
并且我把每个视图的权重= 1。然后将视图添加到LinearLayout。
问题是它不是循环的。
我怎样才能画出像这样的圆形?
我想画的东西是这样的:垂直地画彩条 - 安卓
鉴于条数是动态的,它必须是圆形
我试图把里面的LinearLayout意见水平方向重量和=视图数量(或圆圈内的彩条数量)
并且我把每个视图的权重= 1。然后将视图添加到LinearLayout。
问题是它不是循环的。
我怎样才能画出像这样的圆形?
要做到这一点,你可以用这个图片http://i.stack.imgur.com/YHqsP.png阿凡达
<?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:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/circular_frame"
android:layout_alignLeft="@+id/circular_frame"
android:layout_alignRight="@+id/circular_frame"
android:layout_alignTop="@+id/circular_frame">
<ImageView
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#aa00aa"/>
<ImageView
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#aaaa00"/>
<ImageView
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#0000aa"/>
<ImageView
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#aa0000"/>
<ImageView
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#00aaaa"/>
</LinearLayout>
<FrameLayout
android:id="@+id/circular_frame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/avatar">
</FrameLayout>
</RelativeLayout>
检查[这](http://stackoverflow.com/a/33053086/4440874)的答案。用LinearLayout替换第二个ImageView。 –
@JyotmanSingh在这个答案中角落不会是透明的,他只把图片放在图片的上方。听起来不错,但不是我试图找出什么。 – MBH