欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android移動(dòng)應(yīng)用開發(fā)指南之六種布局詳解

 更新時(shí)間:2022年09月22日 11:25:35   作者:Icy?Hunter  
Android應(yīng)用界面要美觀好看,就需要運(yùn)用到一定的布局技術(shù),Android布局是不可忽視的,是android應(yīng)用界面開發(fā)的重要一環(huán),這篇文章主要給大家介紹了關(guān)于Android移動(dòng)應(yīng)用開發(fā)指南之六種布局的相關(guān)資料,需要的朋友可以參考下

LinearLayout

<?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"
    android:dividerPadding="200dp"
    >

    <LinearLayout
        android:layout_width="100dp"
        android:layout_height="0dp"
        android:background="#ff0000"
        android:layout_weight="1"
        />
    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="#ff000000"
        />
    <LinearLayout
        android:layout_width="100dp"
        android:layout_height="0dp"
        android:background="#ffff00"
        android:layout_weight="1"
        />

    <LinearLayout
        android:layout_width="200dp"
        android:layout_height="00dp"
        android:layout_weight="1"
        android:background="#00ffff" />
</LinearLayout>

orientation設(shè)置排列方式

layout_weight設(shè)置權(quán)重(感覺和彈性盒子差不多)

RelativeLayout

顧名思義,相對(duì)元素布局

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:padding="10dp"
    >
    <RelativeLayout
        android:id="@+id/rl1"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="#ff0000"
        android:layout_centerInParent="true"
        />
    <RelativeLayout
        android:layout_margin="0dp"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="#00ff00"
        android:layout_toLeftOf="@+id/rl1"
        />

</RelativeLayout>

FrameLayout

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <FrameLayout
        android:layout_width="400dp"
        android:layout_height="400dp"
        android:background="#ff0000"
        />
    <FrameLayout
        android:layout_width="300dp"
        android:layout_height="300dp"
        android:background="#ffff00"
        android:foreground="@drawable/a"
        />

    <FrameLayout
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:background="#00ff00"/>

</FrameLayout>

簡(jiǎn)單來說,就是可以疊一起的布局

TableLayout

<?xml version="1.0" encoding="utf-8"?>
<TableLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:collapseColumns=""

    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="第1個(gè)"
        />
    <TableRow>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="第一個(gè)"
            />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="第二個(gè)"
            />
    </TableRow>

    <TableRow>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="第一個(gè)"
            />
    </TableRow>

</TableLayout>

可以看成類似excel的表格一樣的布局

通常結(jié)合< TableRow >一起使用

GridLayout

網(wǎng)格布局

<?xml version="1.0" encoding="utf-8"?>
<GridLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:columnCount="3"
    >
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_row="0"
        android:layout_column="1"
        android:text="第一個(gè)"
        />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="第二個(gè)"
        />
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="第三個(gè)"
        android:layout_columnSpan="3"
        />
</GridLayout>

可以看成TableLayout升級(jí)版?

ConstraintLayout

約束布局

這個(gè)應(yīng)該是最強(qiáng)的布局了

創(chuàng)建布局默認(rèn)的就是這個(gè)了。

打開design模式,然后隨便拖幾個(gè)按鈕進(jìn)去

點(diǎn)擊魔術(shù)棒建立約束。

ok完成布局了。

代碼也自動(dòng)生成好了:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="246dp"
        android:layout_marginTop="107dp"
        android:text="按鈕"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="172dp"
        android:layout_marginBottom="125dp"
        android:text="Button"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent" />

    <Button
        android:id="@+id/button4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="115dp"
        android:text="Button"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

我們開個(gè)虛擬機(jī)運(yùn)行一下:

只能說,差不太多,微調(diào)一下差不多就能用了。

也能夠設(shè)置各個(gè)組件的屬性值顏色字體等等。

這用起來就像是墨刀一樣。

參考

https://www.bilibili.com/video/BV1Jb4y187C4/?p=25&spm_id_from=pageDriver&vd_source=f57738ab6bbbbd5fe07aae2e1fa1280f

總結(jié)

到此這篇關(guān)于Android移動(dòng)應(yīng)用開發(fā)指南之六種布局的文章就介紹到這了,更多相關(guān)Android移動(dòng)應(yīng)用開發(fā)布局內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Android登錄的簡(jiǎn)單處理

    Android登錄的簡(jiǎn)單處理

    這篇文章主要介紹了Android登錄的簡(jiǎn)單處理,一個(gè)簡(jiǎn)易的Demo模擬登錄情況和未登錄情況下的界面跳轉(zhuǎn)處理,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-03-03
  • Android開發(fā)之圖片壓縮工具類完整實(shí)例

    Android開發(fā)之圖片壓縮工具類完整實(shí)例

    這篇文章主要介紹了Android開發(fā)之圖片壓縮工具類,結(jié)合完整實(shí)例形式分析了Android針對(duì)圖片壓縮的相關(guān)屬性設(shè)置與轉(zhuǎn)換操作實(shí)現(xiàn)技巧,需要的朋友可以參考下
    2017-11-11
  • Android編程實(shí)現(xiàn)抽屜效果的方法示例

    Android編程實(shí)現(xiàn)抽屜效果的方法示例

    這篇文章主要介紹了Android編程實(shí)現(xiàn)抽屜效果的方法,結(jié)合具體實(shí)例形式分析了Android抽屜效果的布局、功能實(shí)現(xiàn)及相關(guān)注意事項(xiàng),需要的朋友可以參考下
    2017-06-06
  • Ionic2創(chuàng)建App啟動(dòng)頁左右滑動(dòng)歡迎界面

    Ionic2創(chuàng)建App啟動(dòng)頁左右滑動(dòng)歡迎界面

    使用Ionic2創(chuàng)建應(yīng)用非常簡(jiǎn)單,只需在V1的命令后跟上--v2即可.這篇文章主要介紹了Ionic2創(chuàng)建App啟動(dòng)頁左右滑動(dòng)歡迎界面的相關(guān)資料,需要的朋友可以參考下
    2016-10-10
  • Android實(shí)現(xiàn)模擬搜索功能

    Android實(shí)現(xiàn)模擬搜索功能

    這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)模擬搜索功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-08-08
  • Android仿微信朋友圈添加圖片的實(shí)例代碼

    Android仿微信朋友圈添加圖片的實(shí)例代碼

    本篇文章主要介紹了Android仿微信朋友圈添加圖片的實(shí)例代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-06-06
  • 詳解kotlin中::雙冒號(hào)的使用

    詳解kotlin中::雙冒號(hào)的使用

    在?Kotlin?中?,?::?雙冒號(hào)操作符?的作用是獲取類,對(duì)象,函數(shù),屬性的?類型對(duì)象引用,這篇文章主要介紹了詳解kotlin中::雙冒號(hào)的使用,需要的朋友可以參考下
    2023-04-04
  • NestScrollView嵌套R(shí)ecyclerView實(shí)現(xiàn)淘寶首頁滑動(dòng)效果

    NestScrollView嵌套R(shí)ecyclerView實(shí)現(xiàn)淘寶首頁滑動(dòng)效果

    這篇文章主要介紹了NestScrollView嵌套R(shí)ecyclerView實(shí)現(xiàn)淘寶首頁滑動(dòng)效果,主要實(shí)現(xiàn)淘寶首頁嵌套滑動(dòng),中間tab吸頂效果,以及介紹NestScrollView嵌套R(shí)ecyclerView處理滑動(dòng)沖突的方法,需要的朋友可以參考下
    2021-12-12
  • 探究Android客戶端網(wǎng)絡(luò)預(yù)連接優(yōu)化機(jī)制

    探究Android客戶端網(wǎng)絡(luò)預(yù)連接優(yōu)化機(jī)制

    一般情況下,我們都是用一些封裝好的網(wǎng)絡(luò)框架去請(qǐng)求網(wǎng)絡(luò),對(duì)底層實(shí)現(xiàn)不甚關(guān)注,而大部分情況下也不需要特別關(guān)注處理。了解底層的一些實(shí)現(xiàn),有益于我們對(duì)網(wǎng)絡(luò)加載進(jìn)行優(yōu)化。本文就是關(guān)于根據(jù)http的連接復(fù)用機(jī)制來優(yōu)化網(wǎng)絡(luò)加載速度的原理與細(xì)節(jié)
    2021-06-06
  • Android實(shí)現(xiàn)音樂播放器鎖屏頁

    Android實(shí)現(xiàn)音樂播放器鎖屏頁

    這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)音樂播放器鎖屏頁,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-12-12

最新評(píng)論