Create your account

Already have an account? Login here

Note: By joining, you will receive periodic emails from Coursetro. You can unsubscribe from these emails.

Create account

98. Toggle Compound Drawables on Press

Design + Code an Android App from Scratch

Woah, wait a second..

Scrounge up some loose change to become a pro member, or login to your account to view this lesson.

Alright, join now. Or login to your account if you're already a pro member.

This video shows you how to toggle the compound drawables when it is in a pressed state vs. normal state. We use a layer list drawable for the increment and decrement button in any state. There are two separate layer list drawables for each state: normal and pressed. After detecting whether the top or bottom button is pressed, we use the setCompoundDrawablesWithIntrinsicBounds method to change the drawable for that button corresponding to the desired state.

Course Cirriculum