私は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();
}
}
}
しかし、まだ赤い色の全体のレイアウトは動いていません:( – prabu
他の解決策やアイデア? – prabu
私は自分の答えを編集したことに注意してください。それは私のために働いた。また、この答えを確認してください - > http://stackoverflow.com/questions/25294395/swiperefreshlayout-with-scrollview-and-layout-above?rq=1(私はあなたのScrollViewが問題かもしれないと思う) –