首先!eclipse好强大!eclipse好强大!eclipse好强大!重要的事情要说三遍!安卓将用户界面以XML布局文件的形式单独出来!这点儿让开发变得简单而且高效!最近我的WIFI广告牌终于搞定了点阵流动显示汉字和配置好了串口以及ESP8266!成功让手机和单片机无线通信了!剩下的就是安卓软件的部分了!按照进度!估计两天后才能学完网络编程!然后才开始试着去写属于我自己的第一个APP了!
今天早上试着写了三种布局!
下面我就贴出来纪念一下我......
线性布局
<?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" >
<TextView
android:id="@+id/line_first_text"
android:text="神仙"
android:background="#aa0000"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="35pt"
android:paddingLeft="20dip"
android:paddingTop="10dip"
android:paddingRight="30dip"
android:paddingBottom="50dip"
android:layout_weight="1"
android:singleLine="true"
/>
<TextView
android:id="@+id/line_second_text"
android:text="鬼怪"
android:layout_gravity="center_vertical"
android:background="#00aa00"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="15pt"
android:paddingLeft="50dip"
android:layout_weight="1"/>
</LinearLayout>
表格布局
<pre name="code" class="html"><TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TableRow>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="1"
android:textSize="20pt"
android:background="#00aa00"
android:padding="3dip"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="2"
android:textSize="20pt"
android:background="#aa0000"
android:padding="3dip"/>
</TableRow>
<TableRow>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="3"
android:textSize="20pt"
android:background="#00aa00"
android:padding="3dip"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="4"
android:textSize="20pt"
android:background="#aa0000"
android:padding="3dip"/>
</TableRow>
</TableLayout>
还有相对布局!
<pre name="code" class="html"><?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="@+id/relative_text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="123"
android:background="#aa0000"/>
<TextView
android:id="@+id/relative_text2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="456"
android:layout_below="@id/relative_text1"
android:background="#00aa00"
/>
<Button
android:id="@+id/relative_button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="开始"
android:layout_below="@id/relative_text2"
android:layout_alignRight="@id/relative_text2"
/>
</RelativeLayout>
相对布局挺麻烦!写了简单的三个布局后!我意识到UI设计的工作是多么的繁琐与劳累!!!!就这样吧!要去趟别的学校开会!!!
简单看下效果: