【问题标题】:My imageview not showing up after swiperefreshlayoutswiperefreshlayout 后我的图像视图没有显示
【发布时间】:2018-04-18 04:49:24
【问题描述】:

由于某种原因,我在滑动刷新布局下的 imageview 没有显示出来。 recyclerview 中的元素会正常显示,但 recyclerview 下的任何内容都不会。

<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>

【问题讨论】:

  • 你能分享预期的输出吗
  • 你能分享一下它的截图吗?

标签: android android-layout android-studio swiperefreshlayout


【解决方案1】:

试试这个

<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>

结果

【讨论】:

    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-13
      • 2016-11-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多