【问题标题】:Android: How to Display included layout and listview in one view together?Android:如何在一个视图中同时显示包含的布局和列表视图?
【发布时间】:2017-02-01 15:47:36
【问题描述】:

我想问一下如何在包含的 onde 视图下显示包含的布局和列表视图。

布局:

<android.support.v4.widget.SwipeRefreshLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/swipeContainer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".activity.TransactionsActivity">
    <include
        android:layout_width="fill_parent"
        android:layout_height="10dp"
        android:layout_alignParentTop="true"
        layout="@layout/preloader" />

    <ListView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/list"
        />

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

在预览中只显示包含的布局,不显示下面的lisview。

非常感谢您的建议。

【问题讨论】:

标签: android android-layout include


【解决方案1】:

因为 SwipeRefreshLayout 只接受一个孩子。将其包裹在 LinearLayout 或 RelativeLayout 中。

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

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <include
        layout="@layout/preloader"
        android:layout_width="fill_parent"
        android:layout_height="10dp"
        android:layout_alignParentTop="true" />

    <ListView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</LinearLayout>

祝你好运。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多