1
我已經實現切換按鈕,而不是使用文本圖像,但我怎麼縮放它們Android Studio |如何在ToggleButton中縮放圖像?
我一直在使用scaleType
嘗試,但使用scaleType
這裏也行不通
ic_toggle.xml(我試過,但不起作用)
<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>
原始圖像
這裏的結果我得到了。
這不是我的工作仍像不縮放。但我不知道爲什麼當我將圖像設置爲平方爲什麼圖像仍然扭曲? – TacticalBacon