《第一行代码--Android》阅读笔记之界面设计
1.单位dp、dip、sp、pt、px、in、mm
这里引用StackOverFlow上的一个解答:
- px is one pixel.
- sp is scale-independent pixels.
- dip is Density-independent pixels.( dip == dp is ture)


Density-independent Pixels - an abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi screen, so one dp is one pixel on a 160 dpi screen. The ratio of dp-to-pixel will change with the screen density, but not necessarily in direct proportion. Note: The compiler accepts both "dip" and "dp", though "dp" is more consistent with "sp".
Scale-independent Pixels - this is like the dp unit, but it is also scaled by the user's font size preference. It is recommend you use this unit when specifying font sizes, so they will be adjusted for both the screen density and user's preference.
You would use
spfor font sizesdipfor everything else
android:id="@+id/input_message"android:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:hint="Type something"
android:id="@+id/send"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Send"
super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);ArrayAdapter<String> adapter = new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_list_item_1, data);ListView listView = (ListView) findViewById(R.id.list_view);listView.setAdapter(adapter);
《第一行代码--Android》阅读笔记之界面设计的更多相关文章
- 《第一行代码——Android》
<第一行代码——Android> 基本信息 作者: 郭霖 丛书名: 图灵原创 出版社:人民邮电出版社 ISBN:9787115362865 上架时间:2014-7-14 出版日期:2014 ...
- 历时一年,我的著作《第一行代码——Android》已出版!
前言 事实上我当初决定開始写博客的想法挺简单的,认为自己搞技术这么多年了,总应该要留下点什么.既然没能写出什么出色的应用,那至少也要留下点文字分享给大家,以指引在我后面的开发人员们,毕竟我也从前辈们的 ...
- 20172327 2018-2019-1 《第一行代码Android》第二章学习总结
学号 2017-2018-2 <第一行代码Android>第二章学习总结 教材学习内容总结 - 活动是什么: 活动(Activity)是最容易吸引用户的地方,它是一种可以包含用户界面的组件 ...
- 20172327 2018-2019-1 《第一行代码Android》第一章学习总结
学号 2018-2019-1 <第一行代码Android>第一章学习总结 教材学习内容总结 - Android系统架构: 1.Linux内核层 Android系统是基于Linux内核的,这 ...
- 第一行代码 Android 思维导图
第一行代码 Android 思维导图
- 晒订单赢图灵图书,《第一行代码——Android》福利活动劲爆来袭!
版权声明:本文出自郭霖的博客,转载必须注明出处. https://blog.csdn.net/sinyu890807/article/details/28863515 (已结束) 我的著作<第一 ...
- 第一行代码Android(第3版).pdf下载
2020年人民邮电出版社出版的图书 <第一行代码Android(第3版)>是2020年4月人民邮电出版社出版的图书,作者是郭霖. 封面: 内容简介: <第一行代码 Android 第 ...
- 第一行代码 Android 第二版到货啦
今日android第一行代码[第二版]已到,收获的季节到了 先看一下封面 书签: 以后就把空闲时间送给它吧 先来看一下本书的目录: 第1章 开始启程--你的第1行Android代码 第2章 先从看得到 ...
- 《第一行代码 android》 读书笔记:找出当前界面对应的Activity
在android开发中找出当前界面对应的Activity,步骤如下: 新建一个BaseActivity继承自Activity,然后在BaseActivity中重写onCreate()方法,通过getC ...
随机推荐
- bat操作数据库mysql
createDB.bat文件内容: @echo off cd C:/Program Files/cl_ZWL_App/<a href="http://lib.csdn.net/base ...
- Mysql 学习笔记 20140219
1. Mysql常用命令:每个命令以分号结束. create database name; 创建数据库 use databasename; 选择数据库 dr ...
- nyoj 106 背包问题
点击打开链接 背包问题 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 现在有很多物品(它们是可以分割的),我们知道它们每个物品的单位重量的价值v和重量w(1<=v ...
- SQL备份表及相关笔记
create table history1301( remark nvarchar(64))create table history1302( remark nvarchar(64))create t ...
- elasticsearch从mysql导入数据
详细:https://github.com/jprante/elasticsearch-jdbc(最下面有各数据库的导入方法说明) elasticsearch版本为1.5.2 1.下载 elastic ...
- 【原】linux系统运维工具必备
操作系统:CentOS※,Ubuntu 网站服务:apache,nginx※,tomcat,tengine 开发语言:php,python※,shell※ 数据库 :Mysql※ 代理相关:lvs,k ...
- 11gr2 alert日志中报TNS-12535 TNS-00505原因及解决方法 (转载)
前面新装了11GR2 RAC,某天在做巡检的时候发现alert日志中存在如下报错:Fatal NI connect error 12170. VERSION INFORMATION: T ...
- 01-CALayer的基本操作
*:first-child { margin-top: 0 !important; } body > *:last-child { margin-bottom: 0 !important; } ...
- Debian的一个命令
dpkg是一个Debian的一个命令行工具,它可以用来安装.删除.构建和管理Debian的软件包.下面是它的一些命令解释:1)安装软件命令行:dpkg -i <.deb file name> ...
- MXNet官网案例分析--Train MLP on MNIST
本文是MXNet的官网案例: Train MLP on MNIST. MXNet所有的模块如下图所示: 第一步: 准备数据 从下面程序可以看出,MXNet里面的数据是一个4维NDArray. impo ...