简体   繁体   中英

Android - Override custom view's parent's default attribute values

I have an android custom View called QuizBar which is a subclass of SeekBar . SeekBar sets default values for some of its attributes that are different from the defaults that I want QuizBar to have. What is the best way to change these defaults? I could mess with the AttributeSet passed to the constructor but that would be messy and hard to change. It seems like there would be an easier way to do this.

If you are trying to just change the default value of the progressBackgroundTint and progressBackgroundTintMode then you can just call its setter method within your class's constructor and set its default value.

Remember that both setter methods for the above values are only available for 21 and above so make sure you check the version before you set it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM