webview中的页脚栏没有显示,我将RelativeLayout作为父布局

时间:2018-04-03 10:00:18

标签: android xml webview

webview中的

Click here for the screenshot 页脚栏未显示,我将RelativeLayout作为父布局。页脚栏布局包含“goback”和“gototop”按钮,以便处理上一页加载并转到webview的顶部。从(0,0)位置滚动webview后我需要显示页脚栏。请帮帮我。

<?xml version="1.0" encoding="utf-8"?>

<android.support.constraint.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/nestedScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">


<ProgressBar
    android:id="@+id/fb_progressBar"
    style="@android:style/Widget.ProgressBar.Horizontal"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:maxHeight="5dip"
    android:minHeight="5dip"
    android:progressDrawable="@drawable/progress_horizontal"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

<utilities.ObservableWebView
    android:id="@+id/fb_webView"
    android:layout_width="0dp"
    android:layout_height="0dp"
    app:layout_constraintBottom_toTopOf="@+id/footerBar"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/fb_progressBar"
     />

<RelativeLayout
    android:id="@+id/footerBar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@color/footerBarBg"
    android:paddingBottom="8dp"
    android:paddingTop="8dp"
    android:visibility="visible"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    >

    <ImageView
        android:id="@+id/go_back"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_marginStart="16dp"
        android:background="?attr/selectableItemBackground"
        android:padding="5dp"
        android:src="@drawable/ic_arrow_back_black_24dp" />

    <ImageView
        android:id="@+id/goToTop"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentTop="true"
        android:layout_marginEnd="16dp"
        android:background="?attr/selectableItemBackground"
        android:padding="5dp"
        android:src="@drawable/ic_arrow_upward_black_24dp" />

</RelativeLayout>


</android.support.constraint.ConstraintLayout>

1 个答案:

答案 0 :(得分:0)

<?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"
    android:id="@+id/nestedScrollView"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <utilities.ObservableWebView
        android:id="@+id/fb_webView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/footerBar"
        />

    <RelativeLayout
        android:id="@+id/footerBar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="@color/footerBarBg"
        android:backgroundTint="#ff0000"
        android:paddingBottom="8dp"
        android:paddingTop="8dp"
        android:visibility="visible">

        <ImageView
            android:id="@+id/go_back"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentStart="true"
            android:layout_marginStart="16dp"
            android:background="?attr/selectableItemBackground"
            android:padding="5dp"
            android:src="@drawable/ic_arrow_back_black_24dp" />

        <ImageView
            android:id="@+id/goToTop"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentEnd="true"
            android:layout_alignParentTop="true"
            android:layout_marginEnd="16dp"
            android:background="?attr/selectableItemBackground"
            android:padding="5dp"
            android:src="@drawable/ic_arrow_upward_black_24dp" />

    </RelativeLayout>

    <ProgressBar
        android:id="@+id/fb_progressBar"
        style="@android:style/Widget.ProgressBar.Horizontal"
        android:layout_width="match_parent"
        android:layout_height="5dp"
        android:maxHeight="5dip"
        android:minHeight="5dip"
        android:progressDrawable="@drawable/progress_horizontal" />
</RelativeLayout>

这项工作很完美

或参考本文件 https://stackoverflow.com/a/44778453/7522720