【发布时间】:2017-06-19 08:56:03
【问题描述】:
我试图在从图库中选择一些照片并在片段中显示带有 recyclerview 的列表时显示一个网格视图。如果我不使用滑动刷新布局,我的布局运行良好。你能解决这个为什么在使用滑动刷新布局时这个布局不起作用的原因吗?
xml:
<LinearLayout 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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.systechdigital.webadeal.NewsfeedFragment"
android:orientation="vertical"
android:background="#969696"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#023956"
>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="50dp"
android:src="@drawable/globe"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:id="@+id/notificationButtonId"
android:background="?android:attr/selectableItemBackground"
android:paddingRight="10dp"
/>
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:paddingBottom="10dp"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Share you thoughts here..."
android:paddingLeft="10dp"
android:background="@drawable/edittext_status_background"
android:padding="20dp"
android:elevation="5dp"
android:id="@+id/editTextWritePostId"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:fitsSystemWindows="true"
android:background="#f9f9f9"
>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Post"
android:textColor="#ffffff"
android:background="#1470a6"
android:id="@+id/postButtonId"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/checkInButtonId"
android:layout_toLeftOf="@+id/smileyButtonId"
android:layout_centerInParent="true"
android:src="@drawable/ic_checkin"
android:background="@android:color/transparent"
android:layout_marginRight="3dp"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/smiley"
android:layout_toLeftOf="@+id/imageUploadButtonId"
android:layout_centerInParent="true"
android:layout_marginRight="10dp"
android:id="@+id/smileyButtonId"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/camera"
android:layout_toLeftOf="@+id/videoUploadButtonId"
android:layout_centerInParent="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="10dp"
android:id="@+id/imageUploadButtonId"
/>
</RelativeLayout>
<GridView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/gridViewId"
android:layout_below="@+id/postButtonId"
android:numColumns="auto_fit"
android:columnWidth="100dp"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:layout_marginTop="5dp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/underline"
android:minHeight="0dp"
/>
**<android.support.v4.widget.SwipeRefreshLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/swipeRefreshLayoutId"
>**
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/recyclerviewId_newsFeed"
android:nestedScrollingEnabled="true"
/>
**</android.support.v4.widget.SwipeRefreshLayout>**
</LinearLayout>
</ScrollView>
</LinearLayout>
【问题讨论】:
-
看到这个answer,这一定会对你有所帮助。
-
不工作。,,.,
-
使用 NestedScrollView 而不是 ScrollView。
-
不工作。,.,.