我想畫的東西是這樣的:垂直地畫彩條 - 安卓
鑑於條數是動態的,它必須是圓形
我試圖把裏面的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