最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

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

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設置排列方式

layout_weight設置權重(感覺和彈性盒子差不多)

RelativeLayout

顧名思義,相對元素布局

<?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>

簡單來說,就是可以疊一起的布局

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個"
        />
    <TableRow>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="第一個"
            />

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

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

</TableLayout>

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

通常結合< 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="第一個"
        />

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

可以看成TableLayout升級版?

ConstraintLayout

約束布局

這個應該是最強的布局了

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

打開design模式,然后隨便拖幾個按鈕進去

點擊魔術棒建立約束。

ok完成布局了。

代碼也自動生成好了:

<?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>

我們開個虛擬機運行一下:

只能說,差不太多,微調一下差不多就能用了。

也能夠設置各個組件的屬性值顏色字體等等。

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

參考

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

總結

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

相關文章

  • android客戶端從服務器端獲取json數(shù)據(jù)并解析的實現(xiàn)代碼

    android客戶端從服務器端獲取json數(shù)據(jù)并解析的實現(xiàn)代碼

    今天總結一下android客戶端從服務器端獲取json數(shù)據(jù)的實現(xiàn)代碼,需要的朋友可以參考下
    2013-06-06
  • Android雷達掃描動態(tài)界面制作

    Android雷達掃描動態(tài)界面制作

    這篇文章主要為大家詳細介紹了Android雷達掃描動態(tài)界面制作資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-10-10
  • Android Notification通知使用詳解

    Android Notification通知使用詳解

    消息通知(Notification)是Android系統(tǒng)中比較有特色的一個功能,當某個應用程序希望用戶發(fā)出一些提示信息,而該應用又不在前臺運行時,就可以借助通知來實現(xiàn)
    2022-09-09
  • Android列表RecyclerView排列布局

    Android列表RecyclerView排列布局

    這篇文章主要為大家詳細介紹了Android列表RecyclerView排列布局,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-07-07
  • Android中的Dalvik和ART詳解及區(qū)別分析

    Android中的Dalvik和ART詳解及區(qū)別分析

    小編通過這篇文章給大家整理了什么是Dalvik和ART,并進行了區(qū)別的分析,下面一起來看看。
    2016-07-07
  • Kotlin中雙冒號::使用方法

    Kotlin中雙冒號::使用方法

    這篇文章主要給大家介紹了關于Kotlin中雙冒號::使用的相關資料,文中通過示例代碼介紹的非常詳細,對大家學習或者使用Kotlin具有一定的參考學習價值,需要的朋友們下面來一起學習學習吧
    2019-09-09
  • AndroidManifest.xml <uses-feature>和<uses-permisstion>分析及比較

    AndroidManifest.xml <uses-feature>和<uses-permisstio

    這篇文章主要介紹了AndroidManifest.xml <uses-feature>和<uses-permisstion>分析及比較的相關資料,需要的朋友可以參考下
    2017-06-06
  • Android實現(xiàn)上傳文件功能的方法

    Android實現(xiàn)上傳文件功能的方法

    這篇文章主要介紹了Android實現(xiàn)上傳文件功能的方法,對Android初學者有一定的借鑒價值,需要的朋友可以參考下
    2014-07-07
  • Android Studio調試功能使用匯總

    Android Studio調試功能使用匯總

    這篇文章主要為大家詳細介紹了Android Studio調試功能使用方法,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-05-05
  • Android常用布局使用技巧示例講解

    Android常用布局使用技巧示例講解

    本文詳細介紹了Android常用布局,包括LinearLayout、RelativeLayout、FrameLayout、ConstraintLayout等,分析了它們的適用場景、優(yōu)缺點和使用技巧,幫助開發(fā)者更好地選擇和使用合適的布局,提升UI設計和開發(fā)效率
    2023-04-04

最新評論

丹棱县| 定兴县| 深州市| 潼关县| 密云县| 台湾省| 和平区| 宁晋县| 通河县| 万州区| 鞍山市| 井研县| 吉水县| 文化| 镇宁| 忻城县| 昌乐县| 岐山县| 邹平县| 迁安市| 溧水县| 黔南| 牡丹江市| 从化市| 蒙自县| 舒城县| 济阳县| 如东县| 涿鹿县| 鄂尔多斯市| 陵川县| 依安县| 涿鹿县| 思茅市| 随州市| 策勒县| 长武县| 昆山市| 邵东县| 文化| 常山县|