gpt4 book ai didi

java - SwipeRefreshLayout 在每次刷新后减小我的 View 的大小

转载 作者:行者123 更新时间:2023-12-02 03:50:35 24 4
gpt4 key购买 nike

在我的RecyclerView中,我使用SwipeRefreshLayout。刷新工作正常,我得到了刷新的数据,但是 SwipeRefreshLayout 中的图像(CardViewTextViewsImageViews ,..) 随着每次新的刷新而变得越来越小。

XML 布局:

<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.example.rssreader.MainActivity"
tools:showIn="@layout/activity_main">

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


<android.support.v7.widget.RecyclerView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/recyclerview" />

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/img_fb"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="57dp"
android:src="@mipmap/facebook_icon2" />

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:id="@+id/img_mail"
android:src="@mipmap/mail_icon"
android:layout_alignTop="@+id/img_fb"
android:layout_toLeftOf="@+id/img_fb"
android:layout_toStartOf="@+id/img_fb" />

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


</RelativeLayout>

MainActivity.java,RefreshListener类:

private class MyRefreshListener implements SwipeRefreshLayout.OnRefreshListener {
@Override
public void onRefresh() {
swipeLayout.setRefreshing(false);
new ReadRss(getContext(),recyclerView).execute();


}
}

屏幕截图:

Scaled size

Original size

大家有什么想法吗?想不通。

最佳答案

感谢@g20和@MarioVelasco为我指明了正确的方向,我解决了这个问题。

答案:

The issue was that inside my XmlParser, I was setting some Layout parameters. So onRefresh() executed also then XmlParser, and some Margins were added additionally and again for each refresh.

I moved those parameters outside of my XmlParser class to more appropriate place (for e.g. in MainActivity after initializing the RecyclerView) and now it works as it should.

关于java - SwipeRefreshLayout 在每次刷新后减小我的 View 的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35922716/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com