【发布时间】:2016-03-14 13:52:01
【问题描述】:
我正在尝试使用SwipeToRefreshLayout 来更新标记内的一些信息。虽然我使用android:layout_width="wrap_content" 来保持内容大小,但由于某种原因,它总是填满父级,在信息内容下方留下巨大的空间。我做错了什么?
顺便说一句,如果我没有SwipeRefreshLayout,而只使用ScrollView,则不会出现该空白。
这是我的 XML 代码:
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/svMarker"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/svMarkerInfo">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/llMarkerInfo">
</LinearLayout>
</ScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
感谢您的回答!
我还留下了使用SwipeRefreshLayout 显示的图像。标记信息后面有一张地图:
如果我不使用SwipeRefreshLayout,标记信息将显示在下一个方式,这在视觉上是我正在寻找的。但我错过了 SwipeToRefresh 更新:
【问题讨论】:
-
您还没有在线性布局中添加任何元素吗?尝试添加一些 TextView 或其他东西,以便它可以增加一些高度。
-
我简化了它。将添加一个图像,以便您可以看到它里面有什么。但是,正如我所说,如果我拿走 SwipeRefreshLayout
-
你不能用回收视图代替滚动视图和线性布局吗?这样您就可以设置一个相同的适配器来创建此布局。
-
我可以使用任何必要的东西来解决问题。这就是为什么我要问:)如果你有解决方案,请发布它
-
用户相对布局/线性布局作为父布局。在 Layout 内部用户 SwipeLayout 和其他组件,例如 textviews、buttons。在滑动布局内部使用 Recyclerview。
标签: android android-layout swiperefreshlayout