【问题标题】:Webview + ListView one overlays the other in ActivityWebview + ListView 一个覆盖另一个在 Activity
【发布时间】:2017-07-02 21:09:57
【问题描述】:

所以我有这个 XML 文件:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/viplounge"
android:layout_width="match_parent"
android:layout_height="match_parent"
>

<WebView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/wview"
    android:orientation="vertical"
    android:background="@android:color/black"
    />


    <ListView
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:id="@+id/viplist"
    android:layout_below="@id/wview"
    />
   </RelativeLayout>

WebView 从我的 strings.xml 加载文本的地方,文本使用 HTML 格式化以获得更好的显示体验,并且很长,因此它不适合显示,因此 WebView 是可滚动的。

在 WebView(Text) 下,我正在解析一个 XML 文件,其中包含一些来自 Internet 的数据,这些数据显示在 ListView 中。

所以我的问题是,我无法在我的 WebView 下方获取 ListView,而且我想像这样管理它:当我在 WebView 中滚动完成后,我想在下面显示 ListView。所以用户必须往下看Text/WebView,然后他才能从ListView中读取信息。

该应用程序基本上是在描述一个位置,在描述下应该有该位置可用和不可用的日期列表。只是为了让您了解我在这里做什么。

【问题讨论】:

    标签: android xml listview webview


    【解决方案1】:

    你可以使用NestedScrollView

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    
    <RelativeLayout 
        android:id="@+id/viplounge"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <WebView
            android:id="@+id/wview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@android:color/black"
            android:orientation="vertical" />
    
    
        <ListView
            android:id="@+id/viplist"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/wview" />
    </RelativeLayout>
    </android.support.v4.widget.NestedScrollView>
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-30
    • 2015-06-08
    • 1970-01-01
    • 2017-02-16
    相关资源
    最近更新 更多