Tuesday, December 4, 2012

Android:iPhone like two field Segment Control

Hi fellas


What would we use here is use a Toggle button from android and will apply style on it.

Step 1:

Toggle button in your xml:

  <ToggleButton
                        android:id="@+id/toggleButton"
                        style="@style/style_toggle_button"
                        android:layout_width="130dp"
                        android:layout_height="35dp"
                        android:layout_marginLeft="10dp" />



Step 2 :
Style in /Value

<style name="style_toggle_button">
        <item name="android:background">@drawable/conv_fee_toggle_drawable</item>
        <item name="android:checked">true</item>
        <item name="android:textOff"></item>
        <item name="android:textOn"></item>
        <item name="android:text"></item>
    </style>



Step 3:
conv_fee_toggle_drawable in Drawable

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/percentage" android:state_checked="true"></item>
    <item android:drawable="@drawable/fixed" android:state_checked="false"></item>
</selector>


 Thats it Just place two images percentage on from iphone and fixed on from iphone