开发者

how to change color of image in onTouch?

开发者 https://www.devze.com 2023-02-05 18:00 出处:网络
In my application i have one black and white image, now to want to change the black and white image into colored image like where ever i click on that开发者_如何学Python image only that portion become

In my application i have one black and white image, now to want to change the black and white image into colored image like where ever i click on that开发者_如何学Python image only that portion become colored

Thanks


try this take two different images one is normal image another one is focus image

main.xml code:

<ImageView 
                     android:id="@+id/emailsendimage" 
                     android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:clickable="true"
                     android:focusable="true"                   
                     android:src="@drawable/sendchat_normal_icon" />

next codefile:

 Submit.setOnFocusChangeListener(new OnFocusChangeListener() {

                    public void onFocusChange(View v, boolean hasFocus) {
                        // TODO Auto-generated method stub
                        if(hasFocus){
                             Submit.setImageResource(R.drawable.sendchat_over_icon);
                        }else{
                             Submit.setImageResource(R.drawable.sendchat_normal_icon);
                        }
                    }
                });


Try using Selector for setting different images on different states.

check this and this link out

0

精彩评论

暂无评论...
验证码 换一张
取 消