Android UI设计技巧

本文汇总了Android UI设计中的实用技巧,包括常用颜色代码、透明Activity样式设置、圆角EditText实现方法、SeekBar及ProgressBar定制、ListView定位及滚动操作、使用LinearLayout布局实现特定视图效果等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  • 常用颜色搜集:
    * 手机QQ背景色:#330000ff
    * 字体常用颜色:#333333 -> #555555 -> #999999 ( 深->浅)
    * 半透明背景:0xb0000000 or #b00000000
  • 圆角的EditText:
<EditText
   android:id= "@+id/EditTextTitle"
   android:layout_width= "fill_parent"
   android:layout_height= "wrap_content"
   android:layout_below= "@id/wrapper"
   android:background="@android:drawable/editbox_background"
   android:hint="日志标题"
   android:minHeight= "40dip"
   android:text= "" >
  </EditText >
  • 透明的activity的style:
<style name="blank_activity_theme" parent="AppTheme">
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowAnimationStyle">@android:style/Animation.Translucent</item>
</style>
  • SeekBar或者ProgressBar:
    牛掰博客:http://blog.youkuaiyun.com/w8320273/article/details/7852752
    这里写图片描述

  • Android源码下查看控件样式:

        1. android/frameworks/base/core/res/res/values/styles.xml
        2. 4.0以前SeekBar默认试用了Widget.SeekBar样式;
        3. Holo风格的SeekBar:Widget.Holo.SeekBar;
    
  • 设置listSelector=”#000000”可以将item选中时的黄色背景去掉;

  • ListView定位到指定的位置:listView.setSelection(0);
  • ListView定位到底部:listView.stackFromBottom()=true;
  • 利用LinearLayout巧妙把view放在右边:
<?xml version="1.0" encoding= "utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width= "fill_parent"
    android:layout_height= "50dip"
    android:gravity="center_vertical"
    android:orientation="horizontal" >

    <ImageView
        android:id= "@+id/userIcon"
        android:layout_width= "wrap_content"
        android:layout_height= "wrap_content"
        android:src= "@drawable/user" />

    <TextView
        android:id= "@+id/tvNum"
        android:layout_width="wrap_content"
        android:layout_height= "wrap_content"
        android:layout_marginLeft= "20dip"
        android:layout_weight= "1"
        android:text="10000" />

    <ImageButton
        android:id= "@+id/delButton"
        android:layout_width= "wrap_content"
        android:layout_height= "wrap_content"
        android:background= "@android:color/transparent"
        android:src= "@drawable/delete" />
</LinearLayout>
  • ScrollView滑动到最底端:
// 将scrollView滑动到最底端
       scrollview_game_detail_page.post(new Runnable() {
        public void run() {
         scrollview_game_detail_page.fullScroll(ScrollView.FOCUS_DOWN);
                   }
                 });
  • 详细设置selector:
<?xml version="1.0" encoding="utf-8" ?>  
<selector xmlns:android="http://schemas.android.com/apk/res/android">  
<!-- 没有焦点时的背景颜色 -->  
     <item android:state_window_focused="false"  
         android:drawable="@color/unfocused" />  
     <!-- 非触摸模式下获得焦点并单击时的背景颜色 -->  
     <item android:state_focused="true" android:state_pressed="true"  
         android:drawable="@color/pressed" />  
         <!--触摸模式下单击时的背景颜色  -->  
        <item android:state_focused="false" android:state_pressed="true"  
     android:drawable="@color/white" />  
     <!--选中时的背景颜色  -->  
        <item android:state_selected="true"  android:drawable="@color/selected" />  
         <!--获得焦点时的背景  颜色-->  
        <item android:state_focused="true" android:drawable="@color/focused" />  
</selector>
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值