1

SwipeRefreshLayoutの唯一の子としてRecyclerViewがありますが、RecyclerView wrap_contentが必要です。私は両方の "wrap_content"を設定すると、動作しません。項目が少ないRecyclerViewmatch_parentです。 SwipeRefreshLayoutを削除すると、RecyclerViewwrap_contentになります。誰でも助けてくれますか?私の英語は貧しいです、多分あなたは理解できません。誰でも私を助けることができますか?どうもありがとうございました。SwipeRefreshLayoutのRecyclerViewは "wrap_content"ではありません

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/container_v" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.v4.widget.SwipeRefreshLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="#00ffff"> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/recycler_view" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="#ff00ff"> 


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

+0

ポストXMLコードplz.andは、私はすでに 'SwipeRefreshLayout'に' wrap_content'を設定している、あまりにも –

+0

SwipeRefreshLayoutためwrap_contentを試みるが、 'RecyclerView'も' match_parent'です –

答えて

0
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/container_v" 
    android:layout_width="match_parent" 
    android:weightSum="1" 
    android:orientation="vertical" 
    android:layout_height="match_parent" 
    tools:context=".classes.Splash"> 
    <android.support.v4.widget.SwipeRefreshLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight=".5" 
     android:background="#00ffff"> 

     <android.support.v7.widget.RecyclerView 
      android:id="@+id/recycler_view" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="#ff00ff"> 


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

あなたは

2

最後に、私はそれをうまく動作するリニアlayout.Itに重みを与えて試すことができます。 this Answerから

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/container_v" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.v4.widget.SwipeRefreshLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="#00ffff"> 

    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 

     <android.support.v7.widget.RecyclerView 
      android:id="@+id/recycler_view" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="#ff00ff" /> 


    </LinearLayout> 


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

関連する問題