最近在学习android开发的一些基础知识,当然跟大多数小白一样,都是喜欢去Google搜索一下xxx学习教程或者xxx什么的,不过经过一点小的甄选,感觉csdn推荐的<第一行代码>这本书还比较不错,挺适合我这种菜鸟加小白的。从今天开始,会坚持写一些关于学习过程中的点滴,先从android app的脸蛋UI布局开始吧. Android常用的UI布局应该有LinerLayout(线性布局),RelativeLayout(相对布局)FrameLayout(帧布局)TableLayout(表格布局) 从Google的api guides里面就可以看到,基本常用的还是Linear layout和Relativelayout 以写的一个小的activity跳转的程序界面为例 MainActivity是相对布局,跳转后的SettingActivity是线性布局
<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="com.example.context.MainActivity" >
<TextView
android:id="@+id/tiaozhuan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="跳转到设置程序"
android:textSize="12sp" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tiaozhuan"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:gravity="center"
android:textSize="13sp"
android:text="打开设置" />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="@+id/buttton01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="设置"
android:textSize="12sp" />
<Button
android:id="@+id/buttton02"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="视频通话"
android:textSize="12sp" />
<Button
android:id="@+id/buttton03"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="个人中心"
android:textSize="12sp" />
<Button
android:id="@+id/buttton04"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="K故事"
android:textSize="12sp" />
<Button
android:id="@+id/buttton05"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="小视频"
android:textSize="12sp" />
<Button
android:id="@+id/buttton06"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="哄娃助手"
android:textSize="12sp" />
<Button
android:id="@+id/buttton07"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="返回"
android:textSize="12sp" />
</LinearLayout>