android界面设计源码
A. android app界面设计规范(dpi,dp,px等)
PPI(Pixels per inch):每英寸所拥有的像素数,即像素密度。
DPI(dots per inch):即每英寸上,所能印刷的网点数,一般称为像素密度。ppi计算公式:ppi = 屏幕对角线像素数/屏幕对角线英寸数,通过勾股定理计算屏幕对角线像素数。
Screen Size(屏幕尺寸):手机屏幕尺寸大小,如3英寸、4英寸、4.3英寸、5.7英寸,指的是对角线的长度。
DIP(device independent pixel):即dip/dp,设备独立像素。 1px = 1dp density(由dpi决定)
Resolution(分辨率):指手机屏幕垂直和水平方向上的像素个数。eg分辨率480 800,指该设备垂直方向有800个像素点,水平方向有480个像素点。
px(Pixel像素):相同像素的ui,在不同分辨率的设备上效果不同。在小分辨率设备上会放大导致失真,大分辨率上被缩小。
Android Design里把主流设备的 dpi 归成了四个档次: 120 dpi、160 dpi、240 dpi、320 dpi ,具体见如下表格。
实际开发当中,我们经常需要对这几个尺寸进行相互转换(比如先在某个分辨率下完成设计,然后缩放到其他尺寸微调后输出),一般按照 dpi 之间的比例即 2:1.5:1:0.75 来给界面中的元素来进行尺寸定义。
也就是说如果以 160 dpi 作为基准的话,只要尺寸的 DP 是 4 的公倍数,XHDPI 下乘以 2,HDPI 下乘以 1.5,LDPI 下乘以 0.75 即可满足所有尺寸下都是整数 pixel 。但假设以 240 dpi 作为标准,那需要 DP 是 3 的公倍数,XHDPI 下乘以 1.333,MDPI 下乘以 0.666 ,LDPI 下除以 2。而以 LDPI 和 XHDPI 为基准就更复杂了。同时第一款Android设备(HTC的T-Mobile G1)是属于160dpi的。鉴于以上各种原因, 标准dpi=160
谷歌官方对dp的解释如下:
A virtual pixel unit that you should use when defining UI layout, to express layout dimensions or position in a density-independent way.
The density-independent pixel is equivalent to one physical pixel on a 160 dpi screen, which is the baseline density assumed by the system for a "medium" density screen. At runtime, the system transparently handles any scaling of the dp units, as necessary, based on the actual density of the screen in use. The conversion of dp units to screen pixels is simple: px = dp * (dpi / 160). For example, on a 240 dpi screen, 1 dp equals 1.5 physical pixels. You should always use dp units when defining your application's UI, to ensure proper display of your UI on screens with different densities.
简单来说,以160dpi的设备为准,该设备上1dp = 1px;如果屏幕密度大,1dip代表的px就多,比如在320dpi的屏幕上,1dip=2px(即1dp代表2个像素)。在app开发时,最好用dp来做界面的布局,以保证适配不同屏幕密度的手机。
dp和px的换算公式:
我的理解,该公式表示px的数值等于dp的数值*(设备dpi/160)
注意,px、dp是单位,但density没单位。
applyDimension的源码如下,可参考:
android的尺寸众多,建议使用分辨率为 720x1280 的尺寸设计。这个尺寸 720x1280中显示完美,在 1080x1920 中看起来也比较清晰;切图后的图片文件大小也适中,应用的内存消耗也不会过高。
app启动图标为48*48dp,对应各dpi设备,图像资源像素如下:
| mdpi | hdpi | xhdpi | xxhdpi |
| ---:| ---: | ---:| ---:| ---:|
|48 48px|72 72px|94 96px|144px 144px|
操作栏图标为32*32dp,对应各dpi设备,图像资源像素如下:其中图形区域尺寸是24*24dp,可参考平时ui切图会有部分留白。
| mdpi | hdpi | xhdpi | xxhdpi |
| ---:| ---: | ---:| ---:| ---:|
|32 32px|48 48px|64 64px|96px 96px|
通知栏图标为24*24dp,对应各dpi设备,图标像素如下:
| mdpi | hdpi | xhdpi | xxhdpi |
| ---:| ---: | ---:| ---:| ---:|
|24 24px|36 36px|48 48px|72px 72px|
某些场景需要用到小图标,大小应当是16*16dp,其中图形区域尺寸12*12dp。
| mdpi | hdpi | xhdpi | xxhdpi |
| ---:| ---: | ---:| ---:| ---:|
|16 16px|24 24px|32 32px|48px 48px|
B. 32个实用酷炫的Android开源UI框架
1.Side-Menu.Android
分类侧滑菜单 , Yalantis 出品。
项目地址: https://github.com/Yalantis/Side-Menu.Android
2.Context-Menu.Android
可以方便快速集成漂亮带有动画效果的上下文菜单, Yalantis 出品。
项目地址: https://github.com/Yalantis/Context-Menu.Android
3.Pull-to-Refresh.Rentals-Android
提供一个简单可以自定义的 下拉刷新 实现,Yalantis 出品。
项目地址: https://github.com/Yalantis/Pull-to-Refresh.Rentals-Android
4.Titanic
可以显示水位上升下降的TextView
项目地址: https://github.com/RomainPiel/Titanic
5.AndroidSwipeLayout
滑动Layout ,支持单个View,ListView,GridView
项目地址: https://github.com/daimajia/AndroidSwipeLayout
Demo地址: Download Demo
6.Android Typeface Helper
可以帮你轻松实现自定义字体的库
项目地址: https://github.com/norbsoft/android-typeface-helper
7.android-lockpattern
Android的图案密码解锁
项目地址: https://code.google.com/p/android-lockpattern/
Demo地址: https://play.google.com/store/apps/details?id=group.pals.android.lib.ui.lockpattern.demo
文档介绍: https://code.google.com/p/android-lockpattern/wiki/QuickUse
APP示例:Android开机的图案密码解锁,支付宝的密码解锁
8.ToggleButton
状态切换的 Button,类似 iOS,用 View 实现
项目地址: https://github.com/zcweng/ToggleButton
9.WilliamChart
绘制图表的库,支持LineChartView、BarChartView和StackBarChartView三中图表类型,并且支持 Android 2.2及以上的系统。
项目地址: https://github.com/diogobernardino/WilliamChart
Demo地址: https://play.google.com/store/apps/details?id=com.db.williamchartdemo
Demo项目: https://github.com/diogobernardino/WilliamChart/tree/master/sample
10.实现滑动ViewPager渐变背景色
项目地址: https://github.com/TaurusXi/GuideBackgroundColorAnimation
11.Euclid
用户简历界面, Yalantis 出品。
项目地址: https://github.com/Yalantis/Euclid
12. InstaMaterial
Instagram的一组Material 风格的概念设计
项目地址: https://github.com/frogermcs/InstaMaterial
13. SpringIndicator
使用bezier实现粘连效果的页面指示
项目地址: https://github.com/chenupt/SpringIndicator
14. BezierDemo
仿qq消息气泡拖拽 消失的效果。
项目地址: https://github.com/chenupt/BezierDemo
15. FoldableLayout
折叠的信纸被打开一样的动画效果
项目地址: https://github.com/alexvasilkov/FoldableLayout
16.Taurus
下拉刷新,Yalantis 出品。(是不是有点似曾相识呢?)
项目地址: https://github.com/Yalantis/Taurus
17. PersistentSearch
在点击搜索的时候控件在原有位置显示输入框。
项目地址: https://github.com/Quinny898/PersistentSearch
18. circular-progress-button
带进度显示的Button
项目地址: https://github.com/dmytrodanylyk/circular-progress-button
19. discrollview
当上下滚动的时候子元素会呈现不同动画效果的scrollView,网页上称之为:视差滚动
项目地址: https://github.com/flavienlaurent/discrollview
20. sweet-alert-dialog
一个带动画效果的 自定义对话框样式
项目地址: https://github.com/pedant/sweet-alert-dialog
21. android-floating-action-button
Material Desig风格的 浮动操作按钮
项目地址: https://github.com/futuresimple/android-floating-action-button
22. android-collapse-calendar-view
可以在月视图与周视图之间切换的calendar控件
项目地址: https://github.com/blazsolar/android-collapse-calendar-view
22. android-collapse-calendar-view
可以在月视图与周视图之间切换的calendar控件
项目地址: https://github.com/blazsolar/android-collapse-calendar-view
23. NumberProgressBar
个简约性感的数字进度条
项目地址: https://github.com/daimajia/NumberProgressBar
24. CircularProgressView
CircularProgressView 是通过自定义view的方式实现的Material风格的加载提示控件,兼容任何版本。
项目地址: https://github.com/rahatarmanahmed/CircularProgressView
25. OriSim3D-Android
opengl 实现了各种折纸效果,模拟了从一张纸折叠成一条船的整个过程
项目地址: https://github.com/RemiKoutcherawy/OriSim3D-Android
26、万能日历控件:CalendarView
GitHub: https://github.com/huanghaibin-dev/CalendarView
中文使用文档: https://github.com/huanghaibin-dev/CalendarView/blob/master/QUESTION_ZH.md
27、大图查看器: BigImage ImageView ViewPager
Github: https://github.com/SherlockGougou/BigImageViewPager
地址: https://www.jianshu.com/p/b15e65791c3f
支持超长图、超大图的图片浏览器,优化内存,支持手势放大、下拉关闭、查看原图、加载百分比、保存图片等功能。现已支持androidx。
28、安卓工具包androidUntilCode(安卓必备)
Github: https://github.com/Blankj/AndroidUtilCode/blob/master/lib/utilcode/README-CN.md
29、万能适配器-BRAVH
官网: http://www.recyclerview.org
GitHub: https://github.com/CymChad/BaseRecyclerViewAdapterHelper
RecyclerView
作为Android最常用的控件之一,是否常常为“她”操碎了心
BRVAH受益群体是所有Android开发者,希望更多开发者能够一起来把这个项目做得更好帮助更多人
30、智能刷新控件--SmartRefreshLayout
GitHub: https://github.com/scwang90/SmartRefreshLayout
中文: https://gitee.com/scwang90/SmartRefreshLayout
SmartRefreshLayout以打造一个强大,稳定,成熟的下拉刷新框架为目标,并集成各种的炫酷、多样、实用、美观的Header和Footer。 正如名字所说,SmartRefreshLayout是一个“聪明”或者“智能”的下拉刷新布局,由于它的“智能”,它不只是支持所有的View,还支持多层嵌套的视图结构。 它继承自ViewGroup 而不是FrameLayout或LinearLayout,提高了性能。 也吸取了现在流行的各种刷新布局的优点,包括谷歌官方的 SwipeRefreshLayout , 其他第三方的 Ultra-Pull-To-Refresh 、 TwinklingRefreshLayout 。 还集成了各种炫酷的 Header 和 Footer。
31、内存泄漏检测工具--leakcanary
使用方式: https://www.jianshu.com/p/b83ddffcb3b5
LeakCanary是Square公司基于MAT开源的一个工具,用来检测Android App中的内存泄露问题。官方地址: https://github.com/square/leakcanary
32、 1218683832 / AndroidSlidingUpPanel
SlidingUpPanelLayout:可以上下滑动的菜单布
https://github.com/1218683832/AndroidSlidingUpPanel
C. android界面设计
最下面4个按钮用线性布局放4个button进去.
上面那些,gridview就行了.
D. 如何设计android的登录界面
在网上在到一个登录界面感觉挺不错的,给大家分享一下~先看效果图:
这个Demo除了按钮、小猫和Logo是图片素材之外,其余的UI都是通过代码实现的。
?
一、背景
背景蓝色渐变,是通过一个xml文件来设置的。代码如下:
background_login.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:andro>
<gradient
android:startColor="#FFACDAE5"
android:endColor="#FF72CAE1"
android:angle="45"
/>
</shape>
startColor是渐变开始的颜色值,endColor是渐变结束的颜色值,angle是渐变的角度。其中#FFACDAE5中,FF是Alpha值,AC是RGB的R值,DA是RGB的G值,E5是RGB的B值,每个值在00~FF取值,即透明度、红、绿、蓝有0~255的分值,像要设置具体的颜色,可以在PS上的取色器上查看设置。
?
?
二、圆角白框
效果图上面的并不是白框,其实框是白色的,只是设置了透明值,也是靠一个xml文件实现的。
background_login_div.xml
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:andro>
<solid android:color="#55FFFFFF" />
<!-- 设置圆角
注意: bottomRightRadius是左下角而不是右下角 bottomLeftRadius右下角-->
<corners android:topLeftRadius="10dp" android:topRightRadius="10dp"
android:bottomRightRadius="10dp" android:bottomLeftRadius="10dp"/>
</shape>
?
三、界面的布局
界面的布局挺简单的,就直接贴代码啦~
login.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:andro
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background_login">
<!-- padding 内边距 layout_margin 外边距
android:layout_alignParentTop 布局的位置是否处于顶部 -->
<RelativeLayout
android:
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="15dip"
android:layout_margin="15dip"
android:background="@drawable/background_login_div_bg" >
<!-- 账号 -->
<TextView
android:
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="5dp"
android:text="@string/login_label_username"
/>
<EditText
android:
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/login_username_hint"
android:layout_below="@id/login_user_input"
android:singleLine="true"
android:inputType="text"/>
<!-- 密码 text -->
<TextView
android:
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/username_edit"
android:layout_marginTop="3dp"
android:text="@string/login_label_password"
/>
<EditText
android:
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/login_password_input"
android:password="true"
android:singleLine="true"
android:inputType="textPassword" />
<!-- 登录button -->
<Button
android:
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/password_edit"
android:layout_alignRight="@id/password_edit"
android:text="@string/login_label_signin"
android:background="@drawable/blue_button" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView android:
android:text="@string/login_register_link"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:textColor="#888"
android:textColorLink="#FF0066CC" />
<ImageView android:
android:src="@drawable/cat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginRight="25dp"
android:layout_marginLeft="10dp"
android:layout_marginBottom="25dp" />
<ImageView android:src="@drawable/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/miniTwitter_logo"
android:layout_alignBottom="@id/miniTwitter_logo"
android:paddingBottom="8dp"/>
</RelativeLayout>
</LinearLayout>
E. android手机购物车的界面如何设计求源代码
android手机购物车的界面如何设
肯定比较多,了解分析
大
F. 用Android编写,求像推箱子那种一格一格的界面设计的源代码,先谢谢了!!求发邮箱[email protected]
你这边是 老师安排的作业还是 毕业方面的作业
G. 安卓开发界面设计button无法放到界面底端
换将LinearLayout换成RelativeLayout,采用相对布局使用 android:layout_alignParentBottom="true"就可以把你想要的组建放大父类布局的底端了
H. android 应用界面设计问题,急啊
这个在layout.xml文件里就可以搞定吧?不行就用Java代码动态实现。