安卓前端布局Android,Android开发的几种常见布局
目前正在從事iOS開發(fā),對于安卓就是大學(xué)的時候自學(xué)了點,做過幾個小的項目,軟件外包大賽、計算機設(shè)計大賽、移動應(yīng)用大賽都拿過獎項,呵呵。。。現(xiàn)在回想起來以前大學(xué)做的安卓比賽是多么的幼稚。 從現(xiàn)在開始我要從頭一步一步回顧安卓,作為一個前端開發(fā)工程師要崛起了。。。。哈哈。。。請大家支持的我創(chuàng)作,多提提寶貴的意見。
步入正題!!!!!!!
關(guān)于Android的幾種常見的布局其實很簡單的,是一個入門的關(guān)鍵。主要的線性布局(所有的ui控件都是 以一條線 線性的 方式去 排列的)、相對布局(所有的控件 都是 以相對的位置去放置)、其次表格布局、幀布局(就是頁面的疊加,播放器里經(jīng)常用到)、絕對布局(已廢棄)。
關(guān)于布局就是xml文件里寫。可能有人會說那些標(biāo)簽太多不好記,沒問題,不會的可以去控件里拖拽,時間長了子讓會記住了。我就拿例子來說吧。
線性布局寫的一個小米計算器
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
android:layout_width="fill_parent"
android:layout_height="wrap_content">
android:text="C"
android:textColor="#FFC928"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"/>
android:text="DEL"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"/>
android:text="÷"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"/>
android:text="×"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"/>
android:layout_width="fill_parent"
android:layout_height="wrap_content">
android:text="7"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"/>
android:text="8"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"/>
android:text="9"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"/>
android:text="—"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"/>
android:layout_width="fill_parent"
android:layout_height="wrap_content">
android:text="4"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"/>
android:text="5"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"/>
android:text="6"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"/>
android:text="+"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"/>
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:layout_width="0dip"
android:layout_weight="3"
android:layout_height="wrap_content"
android:orientation="vertical" >
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
android:text="1"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"/>
android:text="2"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"/>
android:text="3"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"/>
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
android:text="0"
android:layout_width="0dip"
android:layout_weight="2"
android:layout_height="wrap_content"/>
android:text="."
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"/>
android:text="="
android:background="#F07A23"
android:layout_width="0dip"
android:layout_weight="1"
android:gravity="bottom|right"
android:layout_height="fill_parent"/>
android:id="@+id/toggleButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ToggleButton" />
線性布局與相對布局混合使用做一個設(shè)置界面
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#113965"
android:orientation="vertical"
tools:context=".MainActivity" >
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#000000" >
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:text="自動旋轉(zhuǎn)屏幕"
android:textColor="#ffffff" />
android:id="@+id/cbx"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true" />
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="#ff0000" />
android:id="@+id/seekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="100"
android:visibility="visible" />
網(wǎng)格布局做的類似qq的登入頁面
android:layout_width="match_parent"
android:layout_height="match_parent" >
android:layout_width="fill_parent"
android:layout_height="wrap_content">
android:text="請輸入QQ"
android:layout_width="0dip"
android:layout_weight="2"
android:layout_height="wrap_content"/>
android:layout_width="0dip"
android:layout_weight="5"
android:layout_height="wrap_content"/>
android:layout_width="fill_parent"
android:layout_height="wrap_content">
android:text="請輸入QQ密碼"
android:layout_width="0dip"
android:layout_weight="2"
android:layout_height="wrap_content"/>
android:layout_width="0dip"
android:layout_weight="5"
android:layout_height="wrap_content"/>
android:text="登入"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
絕對布局做的類似游戲鼠標(biāo)的界面
android:layout_width="match_parent"
android:layout_height="match_parent" >
android:id="@+id/middle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:text="中間" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/middle"
android:layout_centerHorizontal="true"
android:text="上" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/middle"
android:layout_centerHorizontal="true"
android:text="下" />
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="@id/middle"
android:text="左" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@id/middle"
android:text="右" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="左上角" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="14dp"
android:text="左下角" />
幀布局
android:layout_width="match_parent"
android:layout_height="match_parent" >
android:text=""
android:background="#ff0000"
android:layout_width="200dip"
android:layout_height="200dip"/>
android:text=""
android:background="#00ff00"
android:layout_width="100dip"
android:layout_height="100dip"/>
android:text=""
android:background="#0000ff"
android:layout_width="50dip"
android:layout_height="50dip"/>
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎總結(jié)
以上是生活随笔為你收集整理的安卓前端布局Android,Android开发的几种常见布局的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: doip 源码_DoIP协议源码车载以太
- 下一篇: Nginx常见配置:负载均衡、限流、缓存