android布局想要有益于后期维护应该注意什么
PHP中文网
PHP中文网 2017-04-17 17:32:55
0
4
526

比如布局重用之类

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(4)
阿神

1. The main layout file only contains include
2. Naming convention
3. Unified style
4. Don’t overly complicate the nesting level

洪涛

1. Pay attention to the id format. For example, the ID of ListView is lv_xxx, and the ID of TextView is tv_xxx.
2. Pay attention to the meaning of ID. Don't write an ID that is too long, just keep it simple and intuitive, for example: Forum page > Post details > Title TextView. There is no need to write it as tv_forum_post_title, just write it as tv_title
3. Reduce nesting. If you can use FrameLayout, don't use LinearLayout. As for RelativeLayout. . . Personally, I think it should be used as little as possible, as it will generate a bunch of meaningless IDs. . .
4. Reusing layouts is useless in most cases. It is better to extract it directly into a custom view. Write a few properties. This makes it easier to reuse.

迷茫

Ui reuse probability is very low. Common dialog listview actionbar and the like are written in Java, and other codes are extracted depending on the situation. Personal suggestion: Try not to reuse UI except for basic controls. Data coupling is too high

黄舟

In addition, starting from Android Studio 2.2 preview, ConstraintLayout layout was introduced to handle the mutual relationship between components through constraints. In the future, the operation of ui components will become more visual. The adjustment cost of UI is reduced, and the reuse rate of UI is low. Personally, I feel that it does not make much sense to spend a lot of effort to create a reusable layout.
In actual development, only simple components are often extracted, such as search bar, bottom bar, login box, etc. For complex UI, it is often only necessary to comply with some simple specifications. As mentioned above, short and expressive names, unified style, etc.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!