2016-06-22 13 views
1

私はSwipeRefreshLayoutを使って作業しています。私の必要性はここにあります... Imは "赤色"にあるSwipeRefreshLayoutの中で1つのLinearlayoutを使用しています。 そのレイアウトをプルダウンしようとすると、そのレイアウトは動いていません。それだけリフレッシュ円の矢印を示しているが、私はその全体を「赤色」のレイアウトにしたい。これを達成する方法は?アンドロイドで内部がSwipeRefreshLayoutになるとレイアウトが動かないのですか?

私の出典を参考にしてください。

提案して下さい....

mylayout.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="#000000"> 


<android.support.v4.widget.SwipeRefreshLayout 
    android:id="@+id/swipeRefreshLayout_emptyView" 
    android:layout_width="match_parent" 
    android:layout_height="300dp" 
    android:background="#ff0000" 
    > 

    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     > 

     <LinearLayout 
      android:orientation="vertical" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 

      android:gravity="center" 
      > 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Sample SwipeRefreshLayout" 
       android:layout_marginTop="50dp" 
       android:textColor="#ffffff" /> 

     </LinearLayout> 
    </ScrollView> 

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

MyClass.java

public class MyClass extends Fragment implements SwipeRefreshLayout.OnRefreshListener { 

private SwipeRefreshLayout swipeLayout; 

@Nullable 
@Override 
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 
    View view = inflater.inflate(R.layout.mylayout,null); 


    swipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipeRefreshLayout_emptyView); 
    onCreateSwipeToRefresh(swipeLayout); 


    return view; 
} 

private void onCreateSwipeToRefresh(SwipeRefreshLayout swipeLayout) { 

    swipeLayout.setOnRefreshListener(this); 
    swipeLayout.setColorSchemeColors(android.R.color.holo_green_dark, android.R.color.holo_red_dark, 
      android.R.color.holo_blue_dark, android.R.color.holo_orange_dark); 

} 


@Override 
public void onRefresh() { 

    try { 
     Thread.sleep(2000); 
    } catch (InterruptedException e) { 
     e.printStackTrace(); 
    } 
} 
} 

答えて

0

代わりSwipeRefreshLayoutの子としてScrollViewを使用するため、使用してみてくださいa Relativelayout/ScrollViewをその子にします。このような

何か:

<android.support.v4.widget.SwipeRefreshLayout 
    android:id="@+id/swipeRefreshLayout_emptyView" 
    android:layout_width="match_parent" 
    android:layout_height="300dp" 
    > 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="#ff0000"> 
     <ScrollView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      //Leave the interior the same 

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

また、あなたのLinearLayoutに赤い色を適用します。あなたは現在、その高さにwrap_content代わりSwipeRefreshLayoutを

+0

しかし、まだ赤い色の全体のレイアウトは動いていません:( – prabu

+0

他の解決策やアイデア? – prabu

+0

私は自分の答えを編集したことに注意してください。それは私のために働いた。また、この答えを確認してください - > http://stackoverflow.com/questions/25294395/swiperefreshlayout-with-scrollview-and-layout-above?rq=1(私はあなたのScrollViewが問題かもしれないと思う) –

0

あなたのScrollViewでそれを持っています。 Visit this sample

私は自分の問題で解決策を見つけました。 LOL

+0

私はあなたの提案に従ってきましたが、まだそのレイアウトを移動することはできません。 他のソリューションやアイデアはありますか? – prabu

0

使用PullRefreshLayoutをmatch_parentべきではありませんあなたのSwipeRefreshLayout

関連する問題