分享

仿迅雷之Android版

 quasiceo 2015-03-21

分类: Android平台

    由于界面的元素并不是很多,主要是弹窗,字体,位置,弹窗内的布局间距等那么几个,所以基本都是靠dimen来做的,同时稍微在生成弹窗布局的时候,通过代码利用屏幕宽高,利用dimen的值来实现效果,基本还是可以满足需求的;同样: 高手可以指点指点,或者飘过~~~
    dimens.xml - 工程结构在 http://blog./uid-25799257-id-4724749.html 有描述

点击(此处)折叠或打开

  1. <resources>

  2.     <!-- Default screen margins, per the Android Design guidelines. -->
  3.     <dimen name="activity_horizontal_margin">16dp</dimen>
  4.     <dimen name="activity_vertical_margin">16dp</dimen>
  5.     <dimen name="layout_menu_width">180dp</dimen>
  6.     <dimen name="layout_menuItem_width">170dp</dimen>
  7.     <dimen name="half_layout_menu_width">70dp</dimen>
  8.     <dimen name="half_layout_menuIcon_width">50dp</dimen>
  9.     <dimen name="layout_title_barItem_width">35.0dip</dimen>
  10.     <dimen name="myAppPopuWinHeight">98.0dip</dimen>
  11.     <dimen name="myAppPushDataShowTextVHeight">40.0dip</dimen>
  12.     <dimen name="myAppPushDataShowTextVWidth">200.0dip</dimen>
  13.     <dimen name="editSizeWidth">120.0dip</dimen>
  14.     <dimen name="editSizeHeigth">40.0dip</dimen>
  15.     <dimen name="private_tipTVMarginTop">100.0dip</dimen>
  16.     <dimen name="private_tipTVMarginBottom">20.0dip</dimen>
  17.     <dimen name="privatePassSureBtnWidth">80.0dip</dimen>
  18.     <dimen name="privatePassSureBtnHeigth">60.0dip</dimen>
  19.     <dimen name="privatePopuTiptextSize">10.0sp</dimen>
  20.     <dimen name="textSize">18.0sp</dimen>
  21. </resources>
    上面基本都是不同比例下,有一套这样的文件;有些直接在布局中使用,有些在代码中使用,that is it.
    比如(我的没有的分辨率会给出一个默认的9999dip);

点击(此处)折叠或打开

  1. contentView = LayoutInflater.from(context).inflate(R.layout.myapppopuwin, null, true);
  2.         ///< 获取不同分辨率下的我的App的弹窗的尺寸,并且如果没有该尺寸,则设置为屏幕高度的1/4
  3.         float popuWinHeight = this.context.getResources().getDimension(R.dimen.myAppPopuWinHeight);
  4.         if (9999 == popuWinHeight)
  5.         {
  6.             popuWinHeight = ScreenInfo.SCREEN_HEIGHT/4;
  7.         }
  8.         m_popupWindow = new PopupWindow(contentView, LayoutParams.FILL_PARENT, (int)popuWinHeight, true);
    像这种就是直接使用屏幕信息:

点击(此处)折叠或打开

  1. ///< 加载和设置布局
  2.         contentView = LayoutInflater.from(context).inflate(R.layout.privatepopuwin, null, true);
  3.         window = new PopupWindow(contentView, (int)ScreenInfo.SCREEN_WIDTH*2/5, (int)ScreenInfo.SCREEN_HEIGHT*2/5, true);
    当然也是需要在布局文件里面使用dimen的...

点击(此处)折叠或打开

  1. <TextView
  2.         android:id="@+id/private_tipTV"
  3.         android:layout_width="wrap_content"
  4.         android:layout_height="wrap_content"
  5.         android:layout_marginTop="@dimen/private_tipTVMarginTop"
  6.         android:layout_marginBottom="@dimen/private_tipTVMarginBottom"
  7.         android:layout_centerHorizontal="true"
  8.         android:text="@string/privatepassStr"
  9.         android:textSize="@dimen/privatePopuTiptextSize" >
  10.     </TextView>

    最后大体适配了三个分辨率,真机上也做了两个适配,基本ok的。

    到目前基本的本地的功能已经实现,还剩下菜单,删除功能【关于删除可能需要注意,因为删除的内容是在适配器中的,而删除按钮是再header下,不再一个界面,得稍微处理下交换的问题】,应用中心的消息推送完善;已知的Bug,下载时更新进度条的时候,条目间的进度信息显示错乱!!!  有空就接着完善。。。


阅读(1875) | 评论(0) | 转发(1) |
相关热门文章

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多