Wie, um den hintergrund Bild für custom radio-button android mit original-Maßstab?

Brauche ich zur Umsetzung einer Zeitleiste angehängten Bild

Wie, um den hintergrund Bild für custom radio-button android mit original-Maßstab?

Ich versuche es mal mit custom radio-button zu zeichnen, jeden Knoten:
layout-xml - Datei:

<LinearLayout 
android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="2"
    android:orientation="vertical"
    android:layout_gravity="center"
    android:gravity="center"
    android:paddingLeft="50dp"
    android:paddingRight="50dp"
    >
    <RadioGroup 
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:orientation="horizontal"
       android:layout_gravity="center"
       android:gravity="center"
       android:checkedButton="@+id/first">
       <RadioButton android:id="@+id/first"
          style="@style/timeLineRadioButton"/>
       <RadioButton android:id="@+id/second"
          style="@style/timeLineRadioButton"/>
       <RadioButton android:id="@+id/third"
          style="@style/timeLineRadioButton"/>
       <RadioButton android:id="@+id/fourth"
          style="@style/timeLineRadioButton"/>
    </RadioGroup>
</LinearLayout>

res/values/style.xml:

<style name="timeLineRadioButton">
    <item name="android:layout_width">0dp</item>
    <item name="android:layout_weight">1</item>
    <item name="android:gravity">top|center</item>
    <item name="android:layout_height">match_parent</item>
    <item name="android:button">@null</item>
    <item name="android:background">@drawable/button_radio</item>
    <item name="android:scaleType">matrix</item>
</style>

res/drawable/button_radio.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:state_checked="true" android:state_pressed="false"
      android:drawable="@drawable/radio_button_pressed"/>
  <item android:state_checked="false" android:state_pressed="false"
      android:drawable="@drawable/radio_button"/>
  <item android:state_checked="true" android:state_pressed="true"
      android:drawable="@drawable/radio_button_pressed"/>
  <item android:state_checked="false" android:state_pressed="true"
      android:drawable="@drawable/radio_button"/>
</selector>

Die timeline-Anzeige ok, aber hintergrund war die Skala mit unterschiedlichen Verhältnis
Wie, um den hintergrund Bild für custom radio-button android mit original-Maßstab?

so, bitte helfen Sie mir fix hintergrund Bild mit der ursprünglichen ratio-Skala

InformationsquelleAutor Anh Vu | 2014-01-28
Schreibe einen Kommentar