ギャップを持つ円形を作成する必要があります。分割したAndroidのリング形状
クロックを表すプログレスバーを作成しています。各時間に割り当てられた12のギャップ。
これはまさに私が達成したいものです。ここで(デス・スターの外輪)
は私のコードは、これまでのところです:circle_shape.xml
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="ring"
android:innerRadiusRatio="2.5"
android:thickness="4dp"
android:useLevel="false">
<solid android:color="#CCC" />
<stroke
android:dashGap="10px"
android:dashWidth="10px"
android:width="1dp"
android:color="#ababb2" />
</shape>
で
circular_progress_bar
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="270"
android:toDegrees="270">
<shape
android:innerRadiusRatio="2.5"
android:shape="ring"
android:thickness="4dp"
android:useLevel="true"><!-- this line fixes the issue for lollipop api 21 -->
<gradient
android:angle="0"
android:endColor="#007DD6"
android:startColor="#007DD6"
android:type="sweep"
android:useLevel="false" />
</shape>
</rotate>
でactivity.xml
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="200dp"
android:layout_height="200dp"
android:indeterminate="false"
android:progressDrawable="@drawable/circular_progress_bar"
android:background="@drawable/circle_shape"
style="?android:attr/progressBarStyleHorizontal"
android:max="500"
android:progress="65"
android:layout_marginBottom="165dp"
android:layout_above="@+id/button5"
android:layout_centerHorizontal="true" />
で
シェイプをどのように分けると、このように見えますか?私は正しい道にいますか?
あなたはこれをより手の込んだことができます。何処に行くの? Imは完全にアンドロイドに新しいです。いくつかの小さなプロジェクトを通してそれを学ぶことに決めました。これが私の最初のzooperウィジェットの再作成です。 – CBeTJlu4ok
私は完全なクラスとサンプルアプリケーションのためのgithubリンクでより詳細な説明を追加しました。なぜ誰かが私を落胆させたのか分かりませんでした...しかし、おそらくこの問題のためのより良い解決策があります –