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

Android線性布局與相對布局的實現(xiàn)

 更新時間:2022年02月14日 14:15:36   作者:少年白馬  
大家好,本篇文章主要講的是Android線性布局與相對布局的實現(xiàn),感興趣的同學(xué)趕快來看一看吧,對你有幫助的話記得收藏一下

線性布局(LinearLayout)

名字含義
android:id設(shè)置一個id方便使用
android:layout_width寬度
android:layout_height高度
android:background設(shè)置背景顏色
android:layout_margin設(shè)置外邊距
android:layout_padding設(shè)置內(nèi)邊距
android:orientation設(shè)置方向(水平或者垂直)

練習(xí)代碼

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

    <LinearLayout
        android:id="@+id/ll_1"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:orientation="vertical"
        android:background="#000000"
        android:paddingLeft="20dp"
        android:paddingRight="20dp"
        android:paddingTop="50dp"
        android:paddingBottom="10dp">

        <View
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#FF0033"/>

    </LinearLayout>
    
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:orientation="horizontal"
        android:background="#0066FF"
        android:layout_marginTop="20dp"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="15dp">

        <View
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:background="#000000"
            android:layout_weight="1"/>
        <View
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:background="#FF0033"
            android:layout_weight="1"/>
        <View
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:background="#55AA99"
            android:layout_weight="1"/>


    </LinearLayout>

</LinearLayout>

實現(xiàn)效果

請?zhí)砑訄D片描述

相對布局(RelativeLayout)

最常用屬性

名字含義
android:layout_toLeftOf在什么的左邊
android:layout_toRightOf在什么的右邊
android:layout_alignBottom跟什么底部對齊
android:layout_alignParentBottom與父控件底部對齊
android:layout_below在什么的底部

樣例效果

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

    <View
        android:id="@+id/view_1"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="#000000" />

    <View
        android:id="@+id/view_2"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_below="@id/view_1"
        android:background="#FF0033" />

    <LinearLayout
        android:id="@+id/ll_1"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:layout_below="@id/view_2"
        android:background="#0066FF"
        android:orientation="horizontal"
        android:padding="15dp">

        <View
            android:layout_width="100dp"
            android:layout_height="match_parent"
            android:background="#FF0033" />

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#000000"
            android:padding="15dp">

            <View
                android:id="@+id/view_3"
                android:layout_width="100dp"
                android:layout_height="match_parent"
                android:background="#FF9900"/>
            <View
                android:id="@+id/view_4"
                android:layout_width="100dp"
                android:layout_height="match_parent"
                android:background="#FF9900"
                android:layout_toRightOf="@id/view_3"
                android:layout_marginLeft="10dp"/>

        </RelativeLayout>
    </LinearLayout>


</RelativeLayout>

實現(xiàn)效果

[外鏈圖片轉(zhuǎn)存失敗,源站可能有防盜鏈機(jī)制,建議將圖片保存下來直接上傳(img-QfAGp5xf-1644810525369)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20220212100319575.png)]

總結(jié)

到此這篇關(guān)于Android線性布局與相對布局的實現(xiàn)的文章就介紹到這了,更多相關(guān)Android布局內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Android仿探探卡片式滑動效果實現(xiàn)

    Android仿探探卡片式滑動效果實現(xiàn)

    之前在玩探探看著效果圖還可以,然后又在網(wǎng)上看到了一相關(guān)的介紹,便想著自己動手來實踐下,所以下面這篇文章主要介紹了關(guān)于Android實現(xiàn)仿探探卡片式左右滑動效果的相關(guān)資料,需要的朋友可以參考借鑒,下面來一起看看吧。
    2017-03-03
  • Android中實現(xiàn)詞組高亮TextView方法示例

    Android中實現(xiàn)詞組高亮TextView方法示例

    高亮顯示大家應(yīng)該都不陌生,在開發(fā)中經(jīng)常會遇到這個需求,所以下面這篇文章主要給大家介紹了關(guān)于Android中實現(xiàn)詞組高亮TextView的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),需要的朋友可以參考借鑒,下面來一起看看吧。
    2017-10-10
  • 淺談Android為RecyclerView增加監(jiān)聽以及數(shù)據(jù)混亂的小坑

    淺談Android為RecyclerView增加監(jiān)聽以及數(shù)據(jù)混亂的小坑

    下面小編就為大家?guī)硪黄獪\談Android為RecyclerView增加監(jiān)聽以及數(shù)據(jù)混亂的小坑。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-04-04
  • android自定義view實現(xiàn)鐘表效果

    android自定義view實現(xiàn)鐘表效果

    這篇文章主要為大家詳細(xì)介紹了android自定義view實現(xiàn)鐘表效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-12-12
  • Android中SurfaceView和view畫出觸摸軌跡

    Android中SurfaceView和view畫出觸摸軌跡

    這篇文章主要介紹了Android中SurfaceView和view畫出觸摸軌跡的相關(guān)資料,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-03-03
  • Kotlin開發(fā)中open關(guān)鍵字與類名函數(shù)名和變量名的使用方法淺析

    Kotlin開發(fā)中open關(guān)鍵字與類名函數(shù)名和變量名的使用方法淺析

    這篇文檔中,我們將解釋如何以及為什么將 open 關(guān)鍵字與類名、函數(shù)名和變量名一起使用,了解內(nèi)部原理是為了幫助我們做擴(kuò)展,同時也是驗證了一個人的學(xué)習(xí)能力,如果你想讓自己的職業(yè)道路更上一層樓,這些底層的東西你是必須要會的
    2023-02-02
  • Android 系統(tǒng)服務(wù)TelecomService啟動過程原理分析

    Android 系統(tǒng)服務(wù)TelecomService啟動過程原理分析

    這篇文章主要介紹了Android 系統(tǒng)服務(wù)TelecomService啟動過程原理分析,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-07-07
  • Android 分享控件的實現(xiàn)代碼

    Android 分享控件的實現(xiàn)代碼

    這篇文章主要介紹了Android 分享控件的實現(xiàn)代碼,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-03-03
  • Android ScrollView取消慣性滾動的方法

    Android ScrollView取消慣性滾動的方法

    下面小編就為大家?guī)硪黄狝ndroid ScrollView取消慣性滾動的方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-04-04
  • Android編程之圖片顏色處理方法

    Android編程之圖片顏色處理方法

    這篇文章主要介紹了Android編程之圖片顏色處理方法,涉及Android針對圖片的顏色值、飽和度、透明度等處理技巧,具有一定參考借鑒價值,需要的朋友可以參考下
    2015-10-10

最新評論

枞阳县| 南充市| 五华县| 化德县| 新平| 会理县| 江阴市| 江油市| 叶城县| 明水县| 茶陵县| 夏邑县| 博罗县| 巴彦淖尔市| 铜陵市| 广宁县| 孟连| 寻甸| 平泉县| 顺义区| 丹东市| 抚宁县| 西和县| 奉贤区| 额济纳旗| 富锦市| 灯塔市| 桓仁| 班玛县| 平安县| 太康县| 夏津县| 万年县| 葫芦岛市| 河间市| 富民县| 榆中县| 上林县| 漯河市| 漳平市| 鄯善县|