BottomNavigationView隐藏我的webview

时间:2017-04-10 12:22:52

标签: android webview bottomnavigationview

我有一个BottomNavigationView活动。在那里,每当web-view加载一个网站时,我都有一个webview片段。 BottomNavigationView隐藏了我的网络视图的底部,有没有人可以帮我解决这个问题?

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

private void loadContentIntoWebView() {
    String folderName =getFilesDir().getAbsolutePath() + "/cachedFiles";
    String filename = folderName + "/" + "sample.mht";
    File file = new File(filename);

    if (file.exists()) {
        //Using loadUrl of the .mht file, I am able to load the html content.
        webItemContent.loadUrl("file://" + filename);
    } else {
        //Make Server call.
    }
}

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

<?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>

Refer the screenshot

3 个答案:

答案 0 :(得分:2)

你只需要添加一个FrameLayout(它将是你的容器,所以保持其id为android:id =&#34; @ + id / container&#34;)

  

并替换您的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>

答案 1 :(得分:0)

您实际上是在所有布局上添加了您的片段,该布局位于下面的导航栏下方。你应该使用如下的布局,并将你的片段放在内部布局中。

&#13;
&#13;
select d1.name as from_city, d2.name as to_city from lines
inner join destinations d1 on d1.id = lines.dest_from
inner join destinations d2 on d2.id = lines.dest_to
&#13;
&#13;
&#13;

         

答案 2 :(得分:0)

使用 android_layout_height =“ 50dp”(在底部导航中)

并使用 android_layoutmarginBottom =“ 50dp”(在网络视图中)

希望有帮助。