I need a toggle button to have an image and a background color. Currently, my toggle button only has an image and no background color. Here is the code for it
<ToggleButton
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:layout_weight="1.0"
android:layout_margin="5dp"
android:onClick="onToggleClicked"
android:textSize="0sp"
android:checked="false"
android:background="@drawable/soundfocuslone1"/>
<selector xmlns:android="http://ift.tt/nIICcg">
<item android:state_checked="true">
<bitmap android:src="@drawable/soundonlone1"
android:gravity="center"/>
</item>
<item android:state_pressed="true">
<bitmap android:src="@drawable/soundfocuslone1"
android:gravity="center" />
</item>
<item android:state_checked="false">
<bitmap android:src="@drawable/soundofflone1"/>
</item>
</selector>
Is it possible to have two backgrounds on the toggle button? I want a background color as well as an image on it. If not, is there a simple way to have an image button behave like a toggle button? Having an image button acting as a toggle button would probably be easier as the image is not scaled on the toggle button. Thanks, and I would appreciate all replies.
No comments:
Post a Comment