码迷,mamicode.com
首页 > 移动开发 > 详细

ANDROID_MARS学习笔记_S01_004dpi、dp(dip)及计算

时间:2016-02-08 17:19:49      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:

一、dpi、dp介绍

sp会随着用户在手机中设置字体大小而改变,而dp不会

技术分享

 

技术分享

技术分享

二、
1.dpsp_layout.xml

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 3     android:layout_width="match_parent"
 4     android:layout_height="match_parent"
 5     android:orientation="vertical" >
 6     <TextView 
 7         android:layout_width="wrap_content"
 8         android:layout_height="wrap_content"
 9         android:background="#ff0000"
10         android:textSize="50dp"
11         android:text="第一个"/>
12     <TextView 
13         android:layout_width="wrap_content"
14         android:layout_height="wrap_content"
15         android:background="#0000ff"
16         android:textSize="50sp"
17         android:text="第二个"/>
18 
19 </LinearLayout>

 


2.MainActivity.java

 

1     @Override
2     protected void onCreate(Bundle savedInstanceState) {
3         super.onCreate(savedInstanceState);
4         setContentView(R.layout.dpsp_layout);

 

ANDROID_MARS学习笔记_S01_004dpi、dp(dip)及计算

标签:

原文地址:http://www.cnblogs.com/shamgod/p/5184983.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!