最近在學習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>