代码之家  ›  专栏  ›  技术社区  ›  Moi

swiperefreshlayout后未显示My imageview

  •  0
  • Moi  · 技术社区  · 7 年前

    由于某些原因,在“滑动刷新布局”下的“我的图像视图”不会显示。 recyclerview中的元素显示得很好,但recylerview下的任何元素都不会显示。

    <LinearLayout
           xmlns:android="http://schemas.android.com/apk/res/android"
           xmlns:tools="http://schemas.android.com/tools"
           android:layout_width="match_parent"
           android:orientation="vertical"
           android:layout_height="wrap_content"
           tools:context="com.example.disen.chefu.food_categories.second_category">
    
           <android.support.v4.widget.SwipeRefreshLayout
            android:layout_width="wrap_content"
            android:layout_marginBottom="@dimen/activity_horizontal_margin"
            android:id="@+id/refresh_second_catg"
            android:layout_height="wrap_content">
            <android.support.v7.widget.RecyclerView
            android:layout_width="match_parent"
            android:id="@+id/second_category_rcV"
            android:layout_height="wrap_content">
            </android.support.v7.widget.RecyclerView>
            </android.support.v4.widget.SwipeRefreshLayout>
    
            <ImageView
               android:layout_width="wrap_content"
               android:src="@drawable/light"
               android:layout_height="wrap_content" />
           <ProgressBar
             android:layout_width="wrap_content"
             android:id="@+id/second_progress"
             android:visibility="invisible"
             android:layout_gravity="center_horizontal|center_vertical"
             android:indeterminateBehavior="repeat"
             android:layout_height="wrap_content" />
    
    </LinearLayout>
    
    2 回复  |  直到 7 年前
        1
  •  0
  •   Goku Farhana Naaz Ansari    7 年前

    试试这个

    <android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
    
    
       <LinearLayout
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:orientation="vertical">
           <android.support.v7.widget.RecyclerView
               android:id="@+id/second_category_rcV"
               android:layout_width="match_parent"
               android:layout_height="wrap_content" />
    
           <ImageView
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:src="@drawable/ic_launcher_background" />
    
           <ProgressBar
               android:id="@+id/second_progress"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:layout_gravity="center_horizontal|center_vertical"
               android:indeterminateBehavior="repeat"
               android:visibility="visible" />
    
       </LinearLayout>
    </android.support.v4.widget.SwipeRefreshLayout>
    

    后果

    enter image description here

        2
  •  0
  •   Nikhil Gupta    7 年前

    尝试将SwipeRefreshLayout的高度设置为0,权重设置为1。我认为这应该行得通。ImageView不可见的一个可能原因是,在RecyclerView中显示的列表足够大,足以覆盖整个屏幕,并且没有为ImageView留下任何空间。