How to move buttons text when state is pressed

后端 未结 5 800
挽巷
挽巷 2021-01-01 16:19

I made a custom background for a button and also for different button states. But now I made to a point that I cannot understand.

When button is in normal state the

5条回答
  •  暖寄归人
    2021-01-01 16:48

    You can use padding on the view. You can add an OnTouchListener to the button or view like

    viewF.setOnTouchListener(new View.OnTouchListener() {  
        @Override 
        public boolean onTouch(View v, MotionEvent event) { 
            if (event.getAction == MotionEvent.ACTION_UP) { 
                //set your padding            
            } else if (event.getAction == MotionEvent.ACTION_DOWN){
                //set your padding            
            }   
            return true; 
        } 
    }); 
    

    The ontouchlistener will let your know when the button is pressed and not.

提交回复
热议问题