简体   繁体   中英

custom toggle button with image and text

I want to create a toggle button with image on the left of the text. I use this code to make the image on the left:

 <ToggleButton
            android:textOn="Like"
            android:textOff="Liked"
            android:drawableLeft="@drawable/tggle_btn_like"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:checked="false"
           />

However the image is too big. If I set the layout_width and layout_height to a value, the image doens't scale accordingly. My question is how to set with and height for the left drawable of a toggle.

在此处输入图片说明

I want to make it like this

在此处输入图片说明

You can set a padding

paddingRight or paddingLeft

android:paddingLeft="5dp"
android:paddingTop="3dp"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM