zoukankan      html  css  js  c++  java
  • Android studio简单布局之view基本属性

    本人属于自学上路,目前是在入门阶段,所以有些内容实质性比较少,请各位大佬多多包涵。

    视图view的基本属性:

    layout_margin:定义视图与周围视图之间的空白距离

    layout_padding:是指当前视图与内部内容的距离

    线性布局LinearLayout

      layout_gravity:指定该视图与上级视图的对齐方式

      gravity:指定布局内容视图与本视图的对齐方式

    附上实例代码与运行结果:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/RelativeLayout1"
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:background="#ffff99"
        android:orientation="horizontal"
        android:padding="0dp">
    
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="200dp"
            android:layout_weight="1"
            android:layout_gravity="bottom"
            android:gravity="left"
            android:background="#ff0000"
            android:layout_margin="20dp"
            android:padding="20dp"
            android:orientation="vertical"
            >
    
            <View
                android:layout_width="100dp"
                android:layout_height="100dp"
                android:background="#0000ff"/>
    
        </LinearLayout>
    
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="200dp"
            android:layout_weight="1"
            android:layout_gravity="top"
            android:gravity="right"
            android:background="#ff0000"
            android:layout_margin="10dp"
            android:padding="10dp"
            android:orientation="vertical"
            >
    
            <View
                android:layout_width="100dp"
                android:layout_height="100dp"
                android:background="#0000ff"/>
    
        </LinearLayout>
    </LinearLayout>

  • 相关阅读:
    ubuntu11.04更改默认JDK
    10个实用的jQuery交互/通信插件和教程
    jquery 使用方法
    在没有安装 ASP.NET MVC3 的服务器上运行 MVC3
    固定 vs. 流动 vs. 弹性:哪种布局更适合你?[SM]
    提升设计品质的8种布局方案[SM]
    Ubuntu 手动安装JDK
    十个简单好用的设计技巧[SM]
    jQuery VSDoc下载地址
    Ubuntu 配置Apache+PHP+MySQL
  • 原文地址:https://www.cnblogs.com/liberate20/p/10509432.html
Copyright © 2011-2022 走看看