Android如何實現(xiàn)底部菜單固定到底部
今天搞了很久的一個問題,導航菜單沒有固定到底部,因為上面是ListView,可是沒內容,于是就浮動上去了。
效果如下:

這里采用的是一個碎片,代碼是:
<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>
出問題了,百度了很多,試了很多的辦法,沒用。
主頁面代碼:
<?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"-->
<!--內容-->
<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"
也是自己對這個屬性沒有了解清楚,不知道從哪里copy來的一個代碼,這個屬性代碼自動浮動,根據(jù)內容更改大小。所以就造成了我現(xiàn)在的情況。
所以改成:android:layout_height="match_parent" 就好了。

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
- Android實現(xiàn)微博菜單彈出效果
- Android 側滑抽屜菜單的實現(xiàn)代碼
- Android實現(xiàn)動畫效果的自定義下拉菜單功能
- Android實現(xiàn)上下菜單雙向滑動
- Android實現(xiàn)微信加號菜單模式
- Android實現(xiàn)衛(wèi)星菜單效果
- Android自定義轉盤菜單效果
- Android底部菜單欄(RadioGroup+Fragment)美化
- Android recyclerView橫條指示器實現(xiàn)淘寶菜單模塊
- android studio 的下拉菜單Spinner使用詳解
- Android仿新浪微博發(fā)送菜單界面的實現(xiàn)
相關文章
Android利用Service開發(fā)簡單的音樂播放功能
這篇文章主要介紹了Android利用Service開發(fā)簡單的音樂播放功能,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習吧2023-04-04
Android 中使用 dlib+opencv 實現(xiàn)動態(tài)人臉檢測功能
完成 Android 相機預覽功能以后,在此基礎上我使用 dlib 與 opencv 庫做了一個關于人臉檢測的 demo。接下來通過本文給大家介紹Android 中使用 dlib+opencv 實現(xiàn)動態(tài)人臉檢測功能 ,需要的朋友可以參考下2018-11-11
android 中 webview 怎么用 localStorage
這篇文章主要介紹了android 中 webview 怎么用 localStorage方法的相關資料,需要的朋友可以參考下2015-07-07
Android開發(fā)之背景動畫簡單實現(xiàn)方法
這篇文章主要介紹了Android開發(fā)之背景動畫簡單實現(xiàn)方法,涉及Android背景動畫簡單設置與使用技巧,需要的朋友可以參考下2017-10-10
Android Studio啟動報錯Java 1.8 or later is required的解決方法
這篇文章主要為大家詳細介紹了Android Studio啟動時報錯Java 1.8 or later is required的解決方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-03-03
Android項目實戰(zhàn)之ListView懸浮頭部展現(xiàn)效果實現(xiàn)
這篇文章主要給大家介紹了Android項目實戰(zhàn)之ListView懸浮頭部展現(xiàn)效果實現(xiàn)的相關資料,文中通過實例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下2022-01-01

