首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用ListView查看BottomBar

无法使用ListView查看BottomBar
EN

Stack Overflow用户
提问于 2018-02-25 19:50:00
回答 2查看 64关注 0票数 0

我有这样的代码:

代码语言:javascript
复制
<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"/>    

当我使用这个布局时。我看不到底部的栏,只能看到列表视图。在最上面只有列表,没有其他的。

EN

回答 2

Stack Overflow用户

发布于 2018-02-25 19:56:31

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

代码语言:javascript
复制
<?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>
票数 0
EN

Stack Overflow用户

发布于 2018-02-25 20:31:41

  1. 如果您尚未添加父布局,请添加父布局。将列表视图包含在swiperefreshlayout中,并将bottombar和swiperefreshlayout包含在父布局中(例如,相对布局)

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“....> https://medium.com/@chornenkyy.v/first-look-at-bottomnavigationview-from-android-design-library-8244de85b953中建议的design:menu

BottomNavigationView有一个方法菜单(InflateMenu),如果你在里面传递你的菜单资源文件,它将会工作。正确的想法和错误的命名空间出现在我的脑海中,所以我试着用自动解析属性的‘app’命名空间替换‘design’。而且它确实起作用了。专用于此视图的其他三个属性也是如此: itemBackground、itemIconTint、itemTextColor。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48973074

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档