I have implemented ToggleButton to use image instead of text but how do I scale them
I have tried using scaleType
but not work
ic_toggle.xml (I have tried using scaleType
here too but not work)
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="false"
android:drawable="@drawable/ic_signal_p1"/>
<item android:state_checked="true"
android:drawable="@drawable/ic_signal_p2" />
</selector>
fragment_deviceitem_list.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:orientation="vertical">
<ToggleButton
android:id="@+id/scan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_toggle"
android:scaleType="fitCenter"
android:layout_margin="10dp"
android:textOn=""
android:textOff=""
android:focusable="false"
android:focusableInTouchMode="false"
android:layout_centerVertical="true"/>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="63dp"
android:layout_alignParentBottom="true"
android:visibility="visible" />
</RelativeLayout>
Original Image
Here's result I got.