final Button btn_gallery=(Button)findViewById(R.id.btn_gallery);
btn_gallery.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
Intent intentgallery=new Intent(Intent.ACTION_GET_CONTENT);
intentgallery.setType("image/*") ;
startActivityForResult(intentgallery,GALLERY_REQUEST_CODE);
}
});
btn_gallery.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
int action = motionEvent.getAction();
switch (action){
case MotionEvent.ACTION_DOWN:
btn_gallery.setBackgroundResource(R.drawable.galleryyy);
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
btn_gallery.setBackgroundResource(R.drawable.galleryy);
break;
}
return false;
}
});
galleryyy
galleryy (有白边的)
原文:http://www.cnblogs.com/code666/p/6964858.html