Android ui 构建技术分析

1.Android ui 基本技术方式
a. Layout  定义ui  组成
  a1,  LinearLayout
  a2,  FrameLayout
  a3,  TableLayout
  a4,  GrideLayout
  a5,  RelativeLayout
  a6,  Include 
  a7,  Fragment

b.Shape
  <? xml  version =  "1.0"  encoding  = "utf-8" ?>
< shape   xmlns:android = "http://schemas.android.com/apk/res/android"   >
          < solid   android:color = "#ffffffff"   />
     < stroke   android:width =   "8dp"   />
     < corners   android:radius =   "8dp"   />
</ shape >

c. Animation

 alpha animation
  <? xml  version =  "1.0"  encoding  = "utf-8" ?>
< alpha  xmlns:android = "http://schemas.android.com/apk/res/android"
        android:interpolator = "@android:anim/accelerate_interpolator"
        android:fromAlpha = "0.0"  android:toAlpha =  "1.0"  android:duration  = "2000"  />

d.Style
< resources >

     <!--
        Base application theme, dependent on API level. This theme is replaced
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
    -->
     < style  name = "AppBaseTheme"  parent =  "android:Theme.Light" >
         <!--
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.
        -->
     </ style  >

     <!-- Application theme. -->
     < style  name = "AppTheme"  parent =  "AppBaseTheme" >
         <!-- All customizations that are NOT specific to a particular API-level can go here. -->
     </ style  >

</ resources >

e. Menu
< menu  xmlns:android = "http://schemas.android.com/apk/res/android"  >

     < item
         android:id = "@+id/action_settings"
         android:orderInCategory = "100"
         android:showAsAction = "never"
         android:title = "@string/action_settings"  />

</ menu >

Activity 代码中 使用Layout 产生界面可控件布局, 在AndroidManifest.xml中指定 Activity 的Theme 属性使用
Style 文件定义来产生样式,风格。具体的控件可以在布局中指明 Shape 构成背景属性。
Animation 在代码中指定定义(AnimationUtils)创建出对象,然后由控件直接(StartAnimation)使用
eg:
 Animation fade = AnimationUtils.loadAnimation( this , R.anim. fade );
 findViewById(R.id.  imageView1 ).startAnimation(fade);

2. 自定义控件技术
事件接口:base View
 public boolean dispatchTouchEvent(MotionEvent ev):传递Touch事件至target view(可以是自己)。
 public boolean onInterceptTouchEvent(MotionEvent ev):在ViewGroup中定义,用于拦截Touch事件的传递。
 public boolean onTouchEvent(MotionEvent event): Touch事件处理函数。

onInterceptTouchEvent()的机制比较复杂,基本的规则是:

1.事件先路由到顶级的ViewGroup :: onInterceptTouchEvent , 若该函数返回True,将不再向下传递。
2.事件传递到一下一级 ViewGroup 或View,若函数 onInterceptTouchEvent  , 或者 onTouchEvent  返回True,则传递终结,若False,则继续按照深度遍历方式
传递该消息。
3.若一个View接受该事件,并且有能力获取焦点,则后续消息将直接发给该View,忽略掉其它路由过程。

操纵接口: View: public void  scrollTo (int x, int y),
View:public void scrollBy();
View:invalidate() 重绘接口
绘画接口 
private   void  draw(Canvas canvas);




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值