Hack 1. Use Weightsum and Layout_weight.
Question: Try to make a button with a width that is half the effect of the parent view.
Key words: WeightSum = 1, layout_weight=0.5
Hack 2. Common Include and viewstub
Question: How to reduce the drawing time of complex interface.
Keywords: include multiplexing, externally defined layout_width,layout_height;viewstub placeholder, visible settings
Hack 3. Custom ViewGroup
Question: How to calculate the location and size of a child view using a custom ViewGroup
Keywords: custom view,attrs use
Hack 4. Using preference
Android provides classes such as preferenceactivity and preferencefragment to simplify the implementation of preference, so that simple preference can be implemented using them, You can also implement more flexible configurations by inheriting some preference subordinate classes, such as Dialogpreference.
Keywords: Preference, custom Preference
Hack 5. Using Textswitcher/imageswitcher
Question: How do I quickly add animations to multiple text transitions? (similarly image toggle)
Key words: Switcher
Hack 6. Add a uniform sequential animation effect for sub-view ViewGroup subordinates
Question: Animate a child view of a viewgroup with multiple (similar) sub-view
Key words: Layoutanimationcontroller,listview etc
Hack 7.canvas Drawing
Another important part of customizing view, using canvas to draw graphics or images on the screen, custom actions, etc.
Keywords: Canvas
Hack 8. Create Ken Burns effect
Question: How to create an effect like slide transitions
Key words: Animatorset,objectanimator
Hack 9. Use no edittext to enter the data to be tested
Issue: To verify that a user input time format is more troublesome, with the button to detect input lines do not?
Keywords: Customizing background for controls
Hack 10. Formatting the TextView text display
Question: How to implement a simple HTML syntax under TextView, or add a foreground or background color to some text
Key words: Spannablestring,backgroundcolorspan,foregroundcolorspan
Hack 11. Making Luminous Text
Questions raised:
Key words: Typeface,assets/fonts,xml (Shadowcolor,shadowradius,shadowdx,shadowdy)
Example:
Public class extends TextView { public Ledtextview (context context, AttributeSet attrs) { super (context, attrs); = context.getassets (); Final Typeface font = Typeface.createfromasset (assets, "Fonts/digital-7.ttf"); Settypeface (font);} }
Hack 12. Rounded Corners Background
Using drawable can not only use PNG images (especially now Ic_launcher is mipmaps), but also use XML to customize some graphics and status display, such as Press,select
Key words: drawable,xml (Shape corners), shapedrawables
Hack 13. Get the width and height of the view in OnCreate
Problem: The layout method will not be called until the OnCreate call is completed, so the width and height of the view cannot be obtained in OnCreate
keywords, view.post,runable,getwidth,getheight
Hack 16. Setting the Toast location
Keywords: delay show, set gravity
hack.18. Removing the log code with Proguard
Keywords: Androidstudio built-in use of Proguard
Hack 20. Using Model-view-presenter mode
Key words: MVP
Use of Hack 21.SyncAdapter
Key words: Service,provider,syncadapter
Hack 27. Sync settings on activity and adapter via delegate
Keywords: third party Delegate,adapter,view
Hack 41. Ormlite Database
Key words: ORM database in complex case instead of SQLite
Hack 43 Binding A series of database operations
Keywords: applybatch, accelerating large-scale frequent database operations
Android Hacks Reading notes