开发者

how to change color of image in onTouch?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜