简体   繁体   中英

You know sometimes when a button or picture is pressed,

You know sometimes when a button or picture is pressed, and the image gets smaller, then when you release it, it goes back to normal. How would i do that in android studio with an image-button

您可以在按钮上有onclicklisteneronlongPresslistener ,当它按下时,您可以减小用于显示图像的imageview的大小,当释放按钮时,您可以显示原始图像。

create one xml file in drawable like this and set as a background

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/YourHoverImage" android:state_pressed="true"/>
    <item android:drawable="@drawable/NormalImage" android:state_pressed="false"/>
    <item android:drawable="@drawable/YourHoverImage" android:state_focused="true"/>
    <!-- default -->

</selector>

you can do like this.

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