0

我有这个代码:

<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/swipeContainer"
    xmlns:design="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:weightSum="1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:theme="@style/Theme.AppCompat"
    tools:context="com.tag.instagramdemo.example.MainActivity"
    android:background="@drawable/background1">

    <ListView

        android:id="@+id/lvRelationShip"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

    </ListView>
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="64dp"
android:layout_gravity="bottom"
android:background="#ffffff"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:itemIconTint="@color/text"
android:enabled="false"
app:itemTextColor="@color/text"
android:animateLayoutChanges="true"
android:clickable="false"
design:menu = "@menu/menu_main"
android:contextClickable="false"/>    

当我使用这个布局时。我看不到底部栏,我只能看到列表视图。顶部是列表,没有其他内容。

4

2 回答 2

0

我试图解决你的问题。我希望它对你有用:)请看看并尝试

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

    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/swipeContainer"
        android:layout_above="@+id/bottomBar"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:theme="@style/Theme.AppCompat"
        android:weightSum="1">

        <ListView

            android:id="@+id/lvRelationShip"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">

        </ListView>

    </android.support.v4.widget.SwipeRefreshLayout>

    <android.support.design.widget.BottomNavigationView
        android:id="@+id/bottomBar"
        android:layout_width="match_parent"
        android:layout_height="64dp"
        android:layout_alignParentBottom="true"
        android:layout_gravity="bottom"
        android:animateLayoutChanges="true"
        android:background="#ffffff"
        android:clickable="false"
        android:contextClickable="false"
        android:enabled="false"
        design:menu="@menu/navigation" />
</RelativeLayout>
于 2018-02-25T11:56:30.887 回答
0
  1. 如果您尚未添加父布局,请添加父布局。将 listview 包含在 swiperefreshlayout 中,并将底部栏和 swiperefreshlayout 包含在父布局中(例如,相对布局)

    <RelativeLayout 
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:design="http://schemas.android.com/apk/res-auto"
        ....>
        <android.support.v4.widget.SwipeRefreshLayout
            android:id="@+id/swipeContainer"
         ...>
    
             <ListView
                android:id=... >
             </ListView>
         </android.support.v4.widget.SwipeRefreshLayout>
    <android.support.design.widget.BottomNavigationView
        android:id="@+id/bottomBar"
        android:layout_width="match_parent"
        android:layout_height="64dp"
        android:layout_gravity="bottom"
        android:background="#ffffff"
        android:enabled="false"
        app:itemIconTint="@color/colorAccent"
        app:itemTextColor="@color/colorPrimary"
        android:animateLayoutChanges="true"
        android:clickable="false"
        android:contextClickable="false"
        android:layout_below="@id/swipeContainer"
        app:menu = "@menu/menu_main"/>
    

  2. 也使用

应用程序:菜单

而不是https://medium.com/@chornenkyy.v/first-look-at-bottomnavigationview-from-android-design-library-8244de85b953design:menu中的建议

BottomNavigationView 有一个方法 inflateMenu(menu) ,如果您在其中传递菜单资源文件,它将起作用。在我脑海中出现错误命名空间的想法之后,我尝试将“设计”替换为“应用”命名空间,它会自动解析属性。它确实有效。专门为此视图存在的其他三个属性也是如此:itemBackground、itemIconTint、itemTextColor。

于 2018-02-25T12:31:40.640 回答