Android初学者填充和边距之间的差异

我提到了关于SO的问题.还检查了一个答案:
填充是边框内边界和实际视图内容之间的空间.请注意,填充完全围绕内容:顶部,底部,左侧和左侧有填充(可以是独立的).

边距是边框之外的边框之间的边框和旁边的其他元素.在图像中,边距是整个对象之外的灰色区域.请注意,像填充一样,边距完全围绕内容:顶部,右侧和左侧有边距.

此外,更多关于填充和边距从:

http://developer.android.com/reference/android/view/View.html
http://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html

但是填充和利润之间有什么区别呢?行为会因O.S.而异.和设备?
我有一个正常的,简单的布局.没有问题的代码,使用布局文件夹 – 布局和布局sw600dp加drawable-4dpi.不能做出没有边距或填充的布局,哪一个更合适?

解决方法

填料用于内部/内部.例如. TextView,Button,EditText等
例如.文本和边界之间的空间

零件应用于外部.
例如.屏幕左边缘和组件边框之间的空间

视觉表示是伟大的:Difference between a View’s Padding and Margin

使用Padding,我已经看到2.2,2.3和4.3,4.4中有差异
在这种情况下:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:text="ASDFGHJKL" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="15dp"
        android:text="@string/hello_world" />

</RelativeLayout>

另外,检查使用维度:
http://developer.android.com/guide/topics/resources/more-resources.html
http://developer.android.com/samples/BasicSyncAdapter/res/values/dimen.html

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...