安卓前端布局Android,Android開發的幾種常見布局

目前正在從事iOS開發,對于安卓就是大學的時候自學了點,做過幾個小的項目,軟件外包大賽、計算機設計大賽、移動應用大賽都拿過獎項,呵呵。。。現在回想起來以前大學做的安卓比賽是多么的幼稚。 從現在開始我要從頭一步一步回顧安卓,作為一個前端開發工程師要崛起了。。。。哈哈。。。請大家支持的我創作,多提提寶貴的意見。

步入正題!!!!!!!

關于Android的幾種常見的布局其實很簡單的,是一個入門的關鍵。主要的線性布局(所有的ui控件都是 以一條線 線性的 方式去 排列的)、相對布局(所有的控件 都是 以相對的位置去放置)、其次表格布局、幀布局(就是頁面的疊加,播放器里經常用到)、絕對布局(已廢棄)。

關于布局就是xml文件里寫。可能有人會說那些標簽太多不好記,沒問題,不會的可以去控件里拖拽,時間長了子讓會記住了。我就拿例子來說吧。

線性布局寫的一個小米計算器

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" />

線性布局與相對布局混合使用做一個設置界面

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="自動旋轉屏幕"

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" />

網格布局做的類似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"/>

絕對布局做的類似游戲鼠標的界面

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"/>

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/394710.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/394710.shtml
英文地址,請注明出處:http://en.pswp.cn/news/394710.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

《Cocos2D權威指南》——3.9 本章小結

3.9 本章小結 本章對Cocos2D中的幾個核心類(CCNode、CCScene、CCLayer、CCSprite)進行了詳細介紹,并且通過節點層級圖讓大家了解到Cocos2D游戲的基本組成;然后介紹了Cocos2D中的單例。通過完善第2章的游戲實例,大家對…

永恒python圖片_python 數據詞云展示實例(3)- 背景圖設置

記錄wordcloud庫背景圖的設置及樣板 之前介紹了wordcloud的基本使用wordcloud的基本使用,本文記錄一下如何設置背景圖。 樣圖 背景圖tim.jpg 生成樣圖dream.png 樣板 from PIL import Image,ImageSequence image Image.open(tim.jpg)#打開背景圖 graph np.array(im…

創造的快樂

早上9點半到的圖書館,十點左右才進入狀態,上午和下午的一半時間都用來看AMD的GCN架構,看這種官方的文檔,和論文一樣,只看摘要和圖片,沒有死磕的精神,很難有收獲,結果就是&#xff0c…

python心得-基本概念2

一 編程語言介紹 1.1 機器語言:直接用計算機能理解的二進制指令編寫程序,直接控制硬件 1.2 匯編語言:用英文標簽取代二進制指令取編寫程序,本質也是在直接控制硬件 1.3 高級語言:用人能理解的表達方式去編寫程序&#…

初創團隊最重要的是什么_我從一家出色的初創公司工作中學到的最重要的教訓...

初創團隊最重要的是什么by Yan Cui崔燕 我從一家出色的初創公司工作中學到的最重要的教訓 (The most important lessons I learned from working at an amazing startup) I recently left Space Ape Games after a wonderful year. I learnt a lot, and worked on some challe…

企業如何杜絕云端數據泄密?

一直以來,云計算所倡導的就是:“我們可以做得更好,更便宜”。云計算帶給企業諸多利好,但實施云計算必然會加劇信息泄露風險。當企業打算把所有數據傳輸云端的時候,首先要考慮的就是數據保護的問題。 使用云服務&#x…

3dmark for android,Android版3DMark首測

聽到這個消息估計很多像我一樣看膩了3dmark11畫面的跑分黨及玩家們有些許小失望。 每年的12月影馳都會聯合NVIDIA舉辦盛大的嘉年華,今年在武漢舉辦的影馳2012電子競技嘉年華的合作伙伴名單上出現了futumark的身影。Futuremark中國區負責人影馳在當天的平板體驗區也提…

HTML 框架

iframe語法: <iframe src"URL"></iframe>該URL指向不同的網頁。 Iframe - 設置高度與寬度 height 和 width 屬性用來定義iframe標簽的高度與寬度。 屬性默認以像素為單位, 但是你可以指定其按比例顯示 (如&#xff1a;"80%"). 實例 <iframe…

卡方檢驗python程序_Python從零開始第二章(1)卡方檢驗(python)

如果我們想確定兩個獨立分類數據組的統計顯著性&#xff0c;會發生什么&#xff1f;這是卡方檢驗獨立性有用的地方。 Chi-Square檢驗 我們將在1994年查看人口普查數據。具體來說&#xff0c;我們對“性別和“每周工作時間”之間的關系感興趣。在我們的案例中&#xff0c;每個人…

當使用makemigrations時報錯No changes detected

在修改了models.py后&#xff0c;有些用戶會喜歡用python manage.py makemigrations生成對應的py代碼。 但有時執行python manage.py makemigrations命令&#xff08;也可能人比較皮&#xff0c;把migrations文件夾給刪了&#xff09;&#xff0c;會提示"No changes detec…

以下是ECMAScript 2016、2017和2018中所有新增功能的示例

by rajaraodv通過rajaraodv 以下是ECMAScript 2016、2017和2018中所有新增功能的示例 (Here are examples of everything new in ECMAScript 2016, 2017, and 2018) It’s hard to keep track of what’s new in JavaScript (ECMAScript). And it’s even harder to find usef…

win10下markdownpad2顯示問題

win10下解決html渲染問題 下載如下文件安裝后&#xff0c;親測可用 http://markdownpad.com/download/awesomium_v1.6.6_sdk_win.exe轉載于:https://www.cnblogs.com/liuqidongprogram/p/6049295.html

php原生函數應用

php常見基本的函數 一、字符串函數implode — 將一個一維數組的值轉化為字符串 lcfirst — 使一個字符串的第一個字符小寫 ltrim — 刪除字符串開頭的空白字符&#xff08;或其他字符&#xff09; rtrim — 刪除字符串末端的空白字符&#xff08;或者其他字符&#xff09; str_…

android 申請usb權限,USB 權限申請流程

USB android授權方式權限的控制分三塊&#xff1a;1:USB host端有個線程循環檢測系統是否USB設備插拔&#xff0c;如果有就找到申請權限的APP并調用起來2:APP運行后主動申請權限&#xff0c;也就是requestPermission()接口3:APP運行后直接打開USB設備&#xff0c;這時候USB hos…

ai人工智能程序_簡單解釋:一個AI程序如何掌握Go的古老游戲

ai人工智能程序by Aman Agarwal通過阿曼阿加瓦爾(Aman Agarwal) 簡單解釋&#xff1a;一個AI程序如何掌握Go的古老游戲 (Explained Simply: How an AI program mastered the ancient game of Go) This is about AlphaGo, Google DeepMind’s Go playing AI that shook the tec…

python提取hbase數據_詳解python操作hbase數據的方法介紹

配置 thrift python使用的包 thrift 個人使用的python 編譯器是pycharm community edition. 在工程中設置中&#xff0c;找到project interpreter&#xff0c; 在相應的工程下&#xff0c;找到package&#xff0c;然后選擇 “” 添加&#xff0c; 搜索 hbase-thrift (Python cl…

工作隨記

td自動換行:設置table 的 style"table-layout:fixed;" 然后設置td的 style"word-wrap:break-word;" white-space: nowrap 文本不換行 Intelidea創建好項目之后&#xff0c;右鍵新建Java class的時候發現沒有改選項,在Project Structure設置源碼目錄 DOM4j中…

qt for android 圖片可拉伸,qt實現九宮格布局,圖片拉伸

在實現qt播放時&#xff0c;調用的mplayer,由于采用的是自定義繪圖&#xff0c;用的是setAttribute(Qt::WA_TranslucentBackground);結果不能正常在上面顯示播放畫面&#xff0c;在默認皮膚下是沒有問題的&#xff0c;決定用九宮格圖片拉伸方式(效果如圖)附件圖片&#xff1a;文…

第一次作業-李純銳201731084433

作業屬于課程 https://edu.cnblogs.com/campus/xnsy/SoftwareEngineeringClass2 作業要求位置 https://edu.cnblogs.com/campus/xnsy/SoftwareEngineeringClass2/homework/2706 我在這個課程的目標是&#xff1a; 認真學習好軟件工程原理以及科學的軟件項目開發與管理方法&…

定點化_mif文件生成

clc; %全屏清零 clear all; %變量清零 N2^8; %設置ROM深度&#xff08;字變量&#xff09;的變量參數&#xff0c; s_p0:255; …