zoukankan      html  css  js  c++  java
  • 安卓开发

    学习margin和padding的区别,参考菜鸟教程的资料:

    首先margin代表的是偏移,比如marginleft = "5dp"表示组件离容器左边缘偏移5dp; 而padding代表的则是填充,而填充的对象针对的是组件中的元素,比如TextView中的文字 比如为TextView设置paddingleft = "5dp",则是在组件里的元素的左边填充5dp的空间! margin针对的是容器中的组件,而padding针对的是组件中的元素,要区分开来! 下面通过简单的代码演示两者的区别:

    比较示例代码如下:

    <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:id="@+id/btn1"     
            android:layout_height="wrap_content"    
            android:layout_width="wrap_content"    
            android:text="Button"/>    
        <Button    
            android:paddingLeft="100dp"     
            android:layout_height="wrap_content"    
            android:layout_width="wrap_content"    
            android:text="Button"    
            android:layout_toRightOf="@id/btn1"/>    
            
        <Button    
            android:id="@+id/btn2"     
            android:layout_height="wrap_content"    
            android:layout_width="wrap_content"    
            android:text="Button"    
            android:layout_alignParentBottom="true"/>    
        <Button    
            android:layout_marginLeft="100dp"     
            android:layout_height="wrap_content"    
            android:layout_width="wrap_content"    
            android:text="Button"    
            android:layout_toRightOf="@id/btn2"     
            android:layout_alignParentBottom="true"/>    
            
    </RelativeLayout>
  • 相关阅读:
    K近邻法
    感知机
    统计学习方法概论
    神经网络的学习 Neural Networks learing
    对线性回归、逻辑回归、各种回归的概念学习
    从零开始创建VUE项目
    Java中Log4j.properties配置文件详解
    Java中Log4j的入门实例
    Java中Log4j的基本使用方法说明
    C#与Java的RSA中的X509EncodedKeySpec、PKCS8EncodedKeySpec
  • 原文地址:https://www.cnblogs.com/20193898liufa/p/14890472.html
Copyright © 2011-2022 走看看