【问题标题】:Adjust SwipeRefreshLayout height to place View at the bottom of it调整 SwipeRefreshLayout 高度以将 View 置于其底部
【发布时间】:2016-08-02 20:55:58
【问题描述】:

我在RelativeLayout 中有SwipeRefreshLayout。问题是SwipeRefreshLayout 占据了屏幕上的所有位置,我需要在此视图之后放置一个视图

See picture:我有:第一个视图,我需要:屏幕最底部的第二个视图,但顶部有一些空间。

我的示例 XML 是:

<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="wrap_content"
    android:layout_height="wrap_content"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="ru.seniorsolutions.freelansim.Orders"
    tools:showIn="@layout/app_bar_orders"
    android:paddingTop="10dp"
    android:id="@+id/layout_base">

    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/refreshContainer"
        android:layout_width="match_parent"
        android:layout_height="450dp"
        android:layout_marginBottom="30dp">
            <ListView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:id="@+id/lvOffers"
                android:choiceMode="singleChoice"
                android:fastScrollEnabled="false" />
    </android.support.v4.widget.SwipeRefreshLayout>

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="horizontal" android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:paddingLeft="20dp"
        android:paddingRight="20dp"
        android:measureWithLargestChild="false"
        android:layout_alignParentBottom="false"
        android:layout_alignParentLeft="false"
        android:layout_alignParentStart="false"
        android:layout_alignParentEnd="true"
        android:layout_alignBottom="@+id/refreshContainer">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:text="prev"
            android:id="@+id/tvPrevPage"
            android:textColor="#5bb3ee"
            android:textStyle="bold" />

        <View
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_weight="1" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:text="next"
            android:id="@+id/tvNextPage"
            android:textColor="#5bb3ee"
            android:textStyle="bold" />
    </LinearLayout>

</RelativeLayout>

【问题讨论】:

    标签: android android-layout android-relativelayout


    【解决方案1】:

    android:layout_alignParentBottom="true"给你的LinearLayout

    <LinearLayout 
        android:orientation="horizontal" 
        android:layout_width="fill_parent"
        android:layout_alignParentBottom="true
        android:id="@+id/ll"
        .....
    </LinearLayout>
    

    并将SwipeRefreshLayout设置在LinearLayout之上,同时将其高度设置为match_parent

    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/refreshContainer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@id/ll"
        android:layout_marginBottom="30dp">
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-01-11
      • 1970-01-01
      • 1970-01-01
      • 2014-04-17
      • 2016-06-13
      • 2021-10-11
      • 2014-09-12
      相关资源
      最近更新 更多