Ich versuche, eine SeekBar anzupassen, um die Häufigkeit eines Problems in den letzten 6 Monaten zu identifizieren, daher habe ich 4 mögliche Zustände: keine, niedrig, mittel und hoch.Wie kann ich eine benutzerdefinierte SeekBar mit 4 Zuständen wie Androids Priorität erstellen?
Wie ich auf dem Titel identifiziere, möchte ich in der Lage sein, ein Layout wie das folgende Beispiel zu erreichen.
Ich habe versucht, eine SeekBar in das Layout zu legen und andere Layout mit den erwarteten Optionen enthalten. Es ändert jedoch das Aussehen des Verhaltens basierend auf der Bildschirmgröße und wurde unordentlich. Unten ist der verwendete Code:
SeekBar Layout-
<include
android:id="@+id/options"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
layout="@layout/options"
android:layout_alignLeft="@+id/seekBar"
android:layout_alignStart="@+id/seekBar"
android:layout_marginRight="11dp"
android:layout_marginEnd="11dp" />
<SeekBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/seekBar"
android:max="100"
android:layout_below="@+id/options" />
</RelativeLayout>
Optionen Layout-
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/optionN"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:paddingLeft="12dp"
android:text="None" />
<TextView
android:id="@+id/optionL"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:paddingLeft="10dp"
android:text="Low" />
<TextView
android:id="@+id/optionM"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:paddingRight="6dp"
android:text="Medium" />
<TextView
android:id="@+id/optionH"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:paddingRight="8dp"
android:text="High" />
</TableRow>
Haben Sie die 'SeekBar' der max-Wert auf 3 Versuchen Sie, ? Also anstelle von 'android: max =" 100 "' benutze 'android: max =" 3 "', so kann es vier verschiedene Werte haben: 0, 1, 2 und 3. –
versuche diese lib https: // android- arsenal.com/details/1/2511 – xklakoux