随笔--android上遇到的易忽视的区别
来源:互联网 发布:个人软件开发合同范本 编辑:程序博客网 时间:2024/05/29 15:22
1)android:src 与 android:background 的区别:
今天在设置ImageView属性的时候看到src和background属性,以前就以为是一前一后两层图案的区别,总以为如果只要一层图案,src和background二选一即可,今天发觉不是这样的。android:layout_width和android:layout_height等属性是针对src图案的,当android:layout_width=“wrap_content”和android:layout_height=“wrap_content”的时候,如果使用background属性,准备好的图片就很可能会被拉伸变形,而使用src则显示原有比例的图片。
2)VIEW.GONE和VIEW.INVISIBLE的区别:
VIEW.GONE:不显示,也不占用布局空间;
VIEW.INVISIBLE:不显示,但占用布局空间
3)
其实概念很简单,padding是站在父view的角度描述问题,它规定它里面的内容必须与这个父view边界的距离。margin则是站在自己的角度描述问题,规定自己和其他(上下左右)的view之间的距离,如果同一级只有一个view,那么它的效果基本上就和padding一样了。例如我的XML layout代码如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:paddingTop="10dip"
android:paddingBottom="10dip"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#FF0000"
android:text="@string/hello"
android:paddingLeft="50dip"
android:paddingRight="50dip"
android:paddingTop="50dip"
android:paddingBottom="50dip"
android:layout_marginBottom="10dip"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#FF0000"
android:text="@string/hello"
android:paddingLeft="50dip"
android:paddingRight="50dip"
android:paddingTop="50dip"
android:paddingBottom="50dip"
android:layout_marginBottom="10dip"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#FF0000"
android:text="@string/hello"
android:paddingLeft="50dip"
android:paddingRight="50dip"
android:paddingTop="50dip"
android:paddingBottom="50dip"
android:layout_marginBottom="10dip"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#FF0000"
android:text="@string/hello"
android:paddingLeft="50dip"
android:paddingRight="50dip"
android:paddingTop="50dip"
android:paddingBottom="50dip"
android:layout_marginBottom="10dip"
/>
</LinearLayout>
那么我会得到如下的效果,图上已经很明确的标出来区别咯。
- 随笔--android上遇到的易忽视的区别
- 忽视的区别
- 随笔--遇到的问题
- Android 容易忽视的Dialog
- S3C2440 VxWorks移植随笔--初学容易忽视的地方
- android 温故知新之fragment中易忽视的onViewStateRestored()
- Android工具:被你忽视的Lint
- android测试中容易忽视的地方
- 随笔之Android平台上的进程调度探讨
- 随笔之Android平台上的进程调度探讨
- 随笔之Android平台上的进程调度探讨
- 随笔之Android平台上的进程调度探讨
- 随笔之Android平台上的进程调度探讨
- 随笔之Android平台上的进程调度探讨
- 编程的极易忽视的错误
- cms安装遇到的问题随笔
- 随笔,在工作中遇到的问题(杂)
- CMMI实施中易忽视的重要一环
- 更改centos 5 yum源
- 单一职责原则
- Android中Frame的播放介绍
- 360与百度又大战起来了。。。。
- 我心孤寂
- 随笔--android上遇到的易忽视的区别
- 原地踏步
- qt chinese txt
- 持续集成学习笔记-入门篇(5)持续集成自动化(二):具体实现方式一
- java实现对无符号整数的支持
- Rationale
- failed to create the java virtual machine 解决方案
- JAVA实现QCODE解码技术
- MySql的存储过程学习小结