2017-04-10 108 views
0

我有一個BottomNavigationView活動。在那裏,我有一個webview片段,每當網絡視圖加載一個網站。 BottomNavigationView隱藏了我的網絡視圖的底部,有沒有人可以幫我解決這個問題?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> 

這是一個包含web視圖

<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

回答

1

你只是NEET添加的FrameLayout(這將是你容器,以便保持其ID爲機器人:ID =「@ + id/container「)

並更換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> 
+0

當用戶向下滾動webview時,我的應用程序隱藏了操作欄,但是當隱藏時,它會刺激底部導航,爲什麼? –

0

Actully要添加您的片段我的第一個片段碼在您下面的導航下的所有佈局。你應該使用下面的佈局,並把你的片段放在內部佈局中。

<?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" 
 
    > 
 
    <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" 
 
     /> 
 
<RelativeLayout 
 
    android:layout_width="match_parent" 
 
    android:layout_above="@id/navigation" 
 
    android:layout_height="match_parent"> 
 
    <!--Your code for the fragment here.--> 
 
</RelativeLayout> 
 

 
</RelativeLayout>

+0

I HV更換機智你的代碼activity_main.xml中的代碼,但導航視圖消失 –

+0

它的作品添加應用後:菜單=「@菜單/導航「,但同樣的問題發生 –

+0

簡單地將android:id =」@ + id/container「行轉移到內部相對佈局。 –