第四周笔记

用户开发中的布局开发

布局和控件(完成UI设计)

涉及布局layout和控件View

线性布局和相对布局

显示文本TextView  编辑框EditText  属性inputType             点击按钮Button   常用事件及特有事件addTextChangedListener

用于显示数据,图片及其他信息的组件叫View

LinearLayout 线性布局

RelativeLayout 相对布局

AbsoluteLayout 绝对布局

GridView 表格布局

FrameLayout 帧布局

决定垂直或水平的属性为Orientation

   Android:Orientation=“vertical”

相应代码

   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="25dp"

   android:paddingLeft="25dp"

   android:paddingRight="25dp"

   android:paddingTop="25dp"


   tools:context=".MainActivity"

   android:orientation="vertical"

   android:gravity="top"

   android:background="@color/seagreen"

   >


   android:layout_width="match_parent"

   android:layout_height="wrap_content"

   android:orientation="horizontal"

   >

   

       android:layout_width="65dp"

       android:layout_height="wrap_content"

       android:text="用户名"

       android:textSize="16sp"

        />

   

       android:layout_width="200dp"

       android:layout_height="wrap_content"

       android:hint="请输入用户名"

   >

其余与其步骤相似

相对布局

在layout中新建.Xml文件

   android:layout_width="match_parent"

   android:layout_height="match_parent" >

   android:id="@+id/img1"    

   android:layout_width="wrap_content"

   android:layout_height="wrap_content"

   android:src="@drawable/ic_launcher"

   android:layout_centerInParent="true"

   >    


   android:id="@+id/img2"    

   android:layout_width="wrap_content"

   android:layout_height="wrap_content"

   android:src="@drawable/ic_launcher"

   android:layout_above="@id/img1"

   android:layout_centerInParent="true"

>


   android:id="@+id/img4"    

   android:layout_width="wrap_content"

   android:layout_height="wrap_content"

   android:src="@drawable/ic_launcher"

   android:layout_toLeftOf="@id/img1"

   android:layout_alignTop="@id/img1"

   >

其他与其相似

你可能感兴趣的:(第四周笔记)