Android Small UI实际应用总结
2011-02-26 18:06
330 查看
一、Android UI 加速
1、如果某个activity使用了图片作为背景,因为同时默认情况下窗口有一个不透明的背景,删除窗口背景。
2、在视图和布局方面加速UI
(1)使用ViewStub延迟展开视图
(2)使用merge合并中间视图
(3)使用RelativeLayout减少层次
(4)使用自定义视图和布局
(5)使用TextView的drawable××属性,减少层次,如android:drawableLeft,可以在TextView左边放置一个drawable
==============================================================================================================================
二、Android UI使用技巧
1、在Button中放置一张图片,或者在文字的四周放上图片。
2、让TextView带有下划线
3、获取焦点,得到点击相应 android:descendantFocusability
属性值:
beforeDescendants:viewGroup会优于其他控件而获取到焦点
afterDescendants: viewGroup只有子控件不需要的时候才获取焦点
blockDescendants: ViewGroup会覆盖子类控件而直接获取焦点
如果在ListView的item布局中用到了button checkable的子控件,如果使用listview的onitemclickListener的时候,不会相应这个click。这时候就可以使用blockDescendants属性。
1、如果某个activity使用了图片作为背景,因为同时默认情况下窗口有一个不透明的背景,删除窗口背景。
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.screen_shelves); getWindow().setBackgroundDrawable(null);//提高效率 }
2、在视图和布局方面加速UI
(1)使用ViewStub延迟展开视图
(2)使用merge合并中间视图
(3)使用RelativeLayout减少层次
(4)使用自定义视图和布局
(5)使用TextView的drawable××属性,减少层次,如android:drawableLeft,可以在TextView左边放置一个drawable
==============================================================================================================================
二、Android UI使用技巧
1、在Button中放置一张图片,或者在文字的四周放上图片。
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="测试TextView的drawable" android:id="@+id/mess" android:drawableLeft="@drawable/icon" android:drawablePadding="20dip" /> <Button android:drawableLeft="@drawable/icon" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <Button android:drawableLeft="@drawable/icon&<mce:script type="text/javascript" src="http://hi.images.csdn.net/js/blog/tiny_mce/themes/advanced/langs/zh.js" mce_src="http://hi.images.csdn.net/js/blog/tiny_mce/themes/advanced/langs/zh.js"></mce:script><mce:script type="text/javascript" src="http://hi.images.csdn.net/js/blog/tiny_mce/plugins/syntaxhl/langs/zh.js" mce_src="http://hi.images.csdn.net/js/blog/tiny_mce/plugins/syntaxhl/langs/zh.js"></mce:script>quot; android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="测试1" /> <Button android:drawableLeft="@drawable/icon" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="测试2" /> <Button android:drawableLeft="@drawable/icon" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="测试长度要长" /> </LinearLayout>
2、让TextView带有下划线
<resources> <string name="hello"><u>phone: 1390123456</u></string> <string name="app_name">MyLink</string> </resources>
TextView textView = (TextView)findViewById(R.id.testView); textView.setText(Html.fromHtml("<u>"+"hahaha"+"</u>"));
3、获取焦点,得到点击相应 android:descendantFocusability
属性值:
beforeDescendants:viewGroup会优于其他控件而获取到焦点
afterDescendants: viewGroup只有子控件不需要的时候才获取焦点
blockDescendants: ViewGroup会覆盖子类控件而直接获取焦点
如果在ListView的item布局中用到了button checkable的子控件,如果使用listview的onitemclickListener的时候,不会相应这个click。这时候就可以使用blockDescendants属性。
![](file:///C:/Users/zhlu/AppData/Roaming/Tencent/Users/542793413/QQ/WinTemp/RichOle/(Z]DZDSGN%`M6@Q}4)%B]X2.jpg)
相关文章推荐
- android学习总结(二)----MVC在实际中的应用
- android 完全退出应用总结
- Android实际开发常用框架总结
- Android Java概念、关键词理解应用总结-----/*自己编写*/
- java再复习-CountDownLatch的使用与实际应用(Android)
- 链栈的实际应用(总结)
- Android移动应用开发中常见的经验技巧总结
- 使用ionic创建IOS和Android 应用总结
- Android Binder之应用层总结与分析
- android Theme应用总结 (写的真好,我收藏了)
- Android应用测试总结
- android应用开发及系统有用代码片段总结
- Android应用测试方法总结
- android 应用图标放在状态栏上之NotificationManager和Notification的使用总结
- Android五大布局与实际应用详解
- 总结使人进步,可视化界面GUI应用开发总结:Android、iOS、Web、Swing、Windows开发等
- Android应用市场发布经验总结
- Android应用内、外部启动Activity差异总结
- openstack实际应用中问题总结