Android Studio | How do I scale the image in ToggleButton? -


i have implemented togglebutton use image instead of text how scale them

i have tried using scaletype not work

ic_toggle.xml (i have tried using scaletype here 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

enter image description here

here's result got.

enter image description here

try

<togglebutton     android:id="@+id/scan"      android:layout_width="30px"      android:layout_height="30px"     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="wrap_content"     android:layout_alignparentbottom="true"     android:visibility="visible" /> 


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -