Android初学之路(二)

本文分享了作者在学习Android开发过程中,通过实践线性布局、表格布局和相对布局,理解了UI设计的复杂性和细致工作。从XML布局文件入手,实现WIFI广告牌的点阵流动显示汉字和配置串口及ESP8266,成功实现手机与单片机的无线通信。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

首先!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设计的工作是多么的繁琐与劳累!!!!就这样吧!要去趟别的学校开会!!!
简单看下效果:                                                                                                                

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值