layout_marginRight 的用法

来源:互联网 发布:java破解网站验证码 编辑:程序博客网 时间:2024/06/06 01:56

转载:http://www.cnblogs.com/newlist/p/3255348.html

<?xml version = "1.0" encoding = "utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_height="fill_parent"
    android:layout_width="fill_parent"    
    >

    <Button
        android:id="@+id/button_test"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="30dp"
        android:layout_marginLeft="40dp"
        android:layout_marginRight="60dp"
        android:layout_marginBottom="100dp"
        android:text="我是第1个控件"
        android:textSize="12sp" />

    <Button
        android:id="@+id/button_test1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingTop="15sp"
        android:layout_below="@+id/button_test"
        android:paddingLeft="20sp"
        android:layout_gravity="right"
        android:text="我是第2个控件"
        android:textSize="12sp" />

    <ListView
        android:id="@+id/list"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/button_test1" />

</LinearLayout>


<Button
        android:id="@+id/button_test"
        android:layout_width="wrap_content"//大小刚刚可以包住文本
        android:layout_height="wrap_content"
        android:layout_marginTop="30dp"//相对上方控件的距离
        android:layout_marginLeft="40dp"//相对左边控件的距离
        android:layout_marginRight="60dp"//相对右边控件的距离
        android:layout_marginBottom="100dp"//相对下方控件的距离
        android:text="我是第1个控件"
        android:textSize="12sp" />//设置文本的大小

    <Button
        android:id="@+id/button_test1"
        android:layout_width="match_parent"//宽度跟父窗口是一样的
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:paddingTop="15sp"
        android:layout_below="@+id/button_test"//使该控件一直在第一个控件的下方
        android:paddingLeft="20sp"//文本相对控件左边的距离
        android:gravity="right"//表示文本的对齐方式
        android:text="我是第2个控件"
        android:textSize="12sp" />

0 0
原创粉丝点击