Android如何實(shí)現(xiàn)底部菜單固定到底部
今天搞了很久的一個(gè)問(wèn)題,導(dǎo)航菜單沒(méi)有固定到底部,因?yàn)樯厦媸荓istView,可是沒(méi)內(nèi)容,于是就浮動(dòng)上去了。
效果如下:

這里采用的是一個(gè)碎片,代碼是:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <TextView android:id="@+id/card_title_tv" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/background_card" android:gravity="center" android:textSize="18sp"/> <ListView android:id="@+id/jonrney_list_item" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginBottom="48dp" /> </LinearLayout>
出問(wèn)題了,百度了很多,試了很多的辦法,沒(méi)用。
主頁(yè)面代碼:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tl="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#eeeeee"
android:scrollbars="none"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!--android:background="@color/colorPrimaryDark"-->
<!--內(nèi)容-->
<FrameLayout
android:id="@+id/fl_change"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
>
</FrameLayout>
<!-- <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/bottom"
android:layout_alignParentBottom="true" >-->
<!--底部-->
<com.flyco.tablayout.CommonTabLayout
android:id="@+id/tl_3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
tl:tl_indicator_gravity="TOP"
tl:tl_indicator_color="#2C97DE"
tl:tl_textSelectColor="#2C97DE"
tl:tl_textUnselectColor="#66000000"
tl:tl_underline_height="2dp"/>
<!-- </LinearLayout>-->
<!--android:layout_alignParentBottom="true"-->
</LinearLayout>
</android.support.constraint.ConstraintLayout >
最后發(fā)現(xiàn)是這段代碼惹的麻煩:android:layout_height="wrap_content"
也是自己對(duì)這個(gè)屬性沒(méi)有了解清楚,不知道從哪里copy來(lái)的一個(gè)代碼,這個(gè)屬性代碼自動(dòng)浮動(dòng),根據(jù)內(nèi)容更改大小。所以就造成了我現(xiàn)在的情況。
所以改成:android:layout_height="match_parent" 就好了。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- Android實(shí)現(xiàn)微博菜單彈出效果
- Android 側(cè)滑抽屜菜單的實(shí)現(xiàn)代碼
- Android實(shí)現(xiàn)動(dòng)畫(huà)效果的自定義下拉菜單功能
- Android實(shí)現(xiàn)上下菜單雙向滑動(dòng)
- Android實(shí)現(xiàn)微信加號(hào)菜單模式
- Android實(shí)現(xiàn)衛(wèi)星菜單效果
- Android自定義轉(zhuǎn)盤(pán)菜單效果
- Android底部菜單欄(RadioGroup+Fragment)美化
- Android recyclerView橫條指示器實(shí)現(xiàn)淘寶菜單模塊
- android studio 的下拉菜單Spinner使用詳解
- Android仿新浪微博發(fā)送菜單界面的實(shí)現(xiàn)
相關(guān)文章
Android利用Service開(kāi)發(fā)簡(jiǎn)單的音樂(lè)播放功能
這篇文章主要介紹了Android利用Service開(kāi)發(fā)簡(jiǎn)單的音樂(lè)播放功能,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧2023-04-04
Android 中使用 dlib+opencv 實(shí)現(xiàn)動(dòng)態(tài)人臉檢測(cè)功能
完成 Android 相機(jī)預(yù)覽功能以后,在此基礎(chǔ)上我使用 dlib 與 opencv 庫(kù)做了一個(gè)關(guān)于人臉檢測(cè)的 demo。接下來(lái)通過(guò)本文給大家介紹Android 中使用 dlib+opencv 實(shí)現(xiàn)動(dòng)態(tài)人臉檢測(cè)功能 ,需要的朋友可以參考下2018-11-11
android 中 webview 怎么用 localStorage
這篇文章主要介紹了android 中 webview 怎么用 localStorage方法的相關(guān)資料,需要的朋友可以參考下2015-07-07
Android仿iOS側(cè)滑退出當(dāng)前界面功能
這篇文章主要為大家詳細(xì)介紹了Android仿iOS側(cè)滑退出當(dāng)前界面功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-12-12
Android線程的優(yōu)先級(jí)設(shè)置方法技巧
對(duì)于Android平臺(tái)上的線程優(yōu)先級(jí)設(shè)置來(lái)說(shuō)可以處理很多并發(fā)線程的阻塞問(wèn)題,比如很多無(wú)關(guān)緊要的線程會(huì)占用大量的CPU時(shí)間,雖然通過(guò)了MultiThread來(lái)解決慢速I(mǎi)/O但是合理分配優(yōu)先級(jí)對(duì)于并發(fā)編程來(lái)說(shuō)十分重要2016-02-02
Android 為L(zhǎng)istView添加分段標(biāo)頭的方法
下面小編就為大家?guī)?lái)一篇Android 為L(zhǎng)istView添加分段標(biāo)頭的方法。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-04-04
Android開(kāi)發(fā)之背景動(dòng)畫(huà)簡(jiǎn)單實(shí)現(xiàn)方法
這篇文章主要介紹了Android開(kāi)發(fā)之背景動(dòng)畫(huà)簡(jiǎn)單實(shí)現(xiàn)方法,涉及Android背景動(dòng)畫(huà)簡(jiǎn)單設(shè)置與使用技巧,需要的朋友可以參考下2017-10-10
Android Studio啟動(dòng)報(bào)錯(cuò)Java 1.8 or later is required的解決方法
這篇文章主要為大家詳細(xì)介紹了Android Studio啟動(dòng)時(shí)報(bào)錯(cuò)Java 1.8 or later is required的解決方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-03-03
Android項(xiàng)目實(shí)戰(zhàn)之ListView懸浮頭部展現(xiàn)效果實(shí)現(xiàn)
這篇文章主要給大家介紹了Android項(xiàng)目實(shí)戰(zhàn)之ListView懸浮頭部展現(xiàn)效果實(shí)現(xiàn)的相關(guān)資料,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2022-01-01

