android - BottomNavigationView 正在隐藏我的 WebView

标签 android webview bottomnavigationview

我有一个 BottomNavigationView Activity 。其中,每当 WebView 加载网站时,我就有一个 WebView fragment 。 BottomNavigationView 隐藏了我的 WebView 的底部,有没有人可以帮助我解决这个问题?

这是我的activity_main.xml,其中包含BottomNavigationView

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="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="match_parent"
tools:context="com.hackerinside.jaisonjoseph.polysocial.MainActivity">




<android.support.design.widget.BottomNavigationView
    android:id="@+id/navigation"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    android:background="?android:attr/windowBackground"
    android:layout_alignParentBottom="true"
    app:menu="@menu/navigation" />

</RelativeLayout>

这是我的第一个包含 webview 的 fragment 代码

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.hackerinside.jaisonjoseph.polysocial.tab2">


<FrameLayout
    android:id="@+id/frame1"
    android:layout_width="match_parent"
    android:layout_height="3dp"
    android:background="@android:color/transparent">


    <ProgressBar
        android:id="@+id/progressBar1"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="fill_parent"
        android:layout_height="3dp"
        android:background="@android:color/transparent"
        android:foregroundGravity="top"
        android:progressDrawable="@drawable/custom_progress"
        android:progress="20"/>

</FrameLayout>


<android.support.v4.widget.SwipeRefreshLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/swiperefresh1"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.hackerinside.jaisonjoseph.polysocial.EulaWebView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/webview"
        android:focusable="true"
        android:focusableInTouchMode="true" />

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

</LinearLayout>

Refer the screenshot

最佳答案

您只需要添加一个 FrameLayout (这将是您的容器,因此请将其 id 保留为 android:id="@+id/container")

and replace your code of activity_main.xml

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

>


    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/container"
        android:layout_above="@+id/navigation"
        >

    </FrameLayout>
    <android.support.design.widget.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:background="?android:attr/windowBackground"
        android:layout_alignParentBottom="true"
        app:menu="@menu/navigation" />

</RelativeLayout>

关于android - BottomNavigationView 正在隐藏我的 WebView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43323055/

相关文章:

android - 如何通过android在Firebase中添加子节点?

java - 如何在android studio中修复(资源@drawable/abc_vector_test在androix.appcompat :appcompat)中标记为私有(private)

android - 使用WebView的安全风险(IOS、Android)

带有后退按钮的 Android Webview,否则

android - 如何在 Android 导航组件中管理 BottomNavigationView 后台堆栈

android - NavigationUI 无法与底部导航 View 实现一起正常工作

java - 使用 ImageView 创建自定义 View ,Asynctask 不工作

android - 如何使 View 在触摸事件时可调整大小

java - 如何制作对话框 "You are using 3G. Connect to WiFi"?

android - android 底部导航栏中的项目超过 3 个