Development Summary 1: Development Summary 1
Project UI Summary
Today, I sorted out the project UI for one day, and gave it to me to get closer to the original prototype design and UI artist. After one day of Project reconstruction and code optimization.
Similar to more list items
In development, we usually extract a common item as a template, and then use the adapter for data adaptation. If this is just a fixed number list. We may use linear layout LinearLayout and place several layout S. At this time, there is a problem. If there are many menus with the same layout in this App, can I write the code one by one like me?
<LinearLayout android: layout_width = "match_parent" android: layout_height = "30dp" android: background = "# ffebe6" android: gravity = "center" android: visibility = "gone" android: id = "@ + id/position_bar" android: orientation = "vertical"> <TextView android: layout_width = "wrap_content" android: layout_height = "match_parent" android: layout_gravity = "center" android: drawableLeft = "@ drawable/tips_icon" android: drawablePadding = "8dp" android: gravity = "center" android: text = "insufficient deposit, please append "android: textColor =" #333333 "android: textSize =" 12sp "/> </LinearLayout>
If there are only two or three entries in the project, it may be understandable. If there are eight in Activity A, eight in Activity B, or more in other projects, at this time, you should think about whether to refactor your code. In this caseStyleWe should consider making it appear. So I used the automatic extract function of Android studio to reconstruct a Style and asked the IDE to help me replace this large amount of reusable code in the entire process.
<style name="position_tile_item"> <item name="android:layout_width">wrap_content</item> <item name="android:layout_height">wrap_content</item> <item name="android:drawableLeft">@drawable/red_dot</item> <item name="android:drawablePadding">3dp</item> <item name="android:textSize">12sp</item> <item name="android:textColor">#333333</item> <item name="android:textAppearance">?android:attr/textAppearanceSmall</item> </style>
This is a Style that I used by IDE to reconstruct for me. I just need to reference the Style directly in the subsequent sections.
Later, my code becomes more streamlined. As follows:
<LinearLayout android: layout_width = "match_parent" android: layout_height = "match_parent" android: layout_marginLeft = "15dp" android: layout_weight = "1" android: gravity = "weight" android: orientation = "horizontal"> <TextView style = "@ style/position_tile_item" android: text = "share:"/> <TextView style = "@ style/positin_title2_style" android: text = "9891315.65"/> <TextView style = "@ style/position_title3_item" android: text = ""/> </LinearLayout>
Perhaps, here, in fact, this article does not cover any advanced methods.
Purpose of this article:
- Sort out my daily project summary and study notes.
- My thoughts on publishing notes
- Write and publish learning experiences
- I usually reach out to the party and start to repent for myself, and contribute some of my strength to open source.
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.