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 Studio中添加RecyclerView-v7支持包
本篇文章主要介紹了詳解如何在Android Studio中添加RecyclerView-v7支持包,具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-02-02Android實現(xiàn)音頻條形圖效果(仿音頻動畫無監(jiān)聽音頻輸入)
這篇文章主要介紹了Android實現(xiàn)音頻條形圖效果(仿音頻動畫無監(jiān)聽音頻輸入)的相關資料,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2016-09-09Android基于ViewPager實現(xiàn)的應用歡迎界面完整實例
這篇文章主要介紹了Android基于ViewPager實現(xiàn)的應用歡迎界面,結合完整實例形式分析了ViewPager類用于歡迎界面顯示圖片的具體步驟與相關操作技巧,需要的朋友可以參考下2016-08-08Android 日歷控件庫,可左右滑動,顯示公歷,農歷,節(jié)假日等功能
這篇文章主要介紹了Android 日歷控件庫,可左右滑動,顯示公歷,農歷,節(jié)假日等功能的相關資料,需要的朋友可以參考下2016-09-09Android實現(xiàn)動態(tài)切換組件背景的方法
這篇文章主要介紹了Android實現(xiàn)動態(tài)切換組件背景的方法,需要的朋友可以參考下2014-07-07