Browse Source

修复图片展示不全的问题

詹子聪 5 years ago
parent
commit
082753d8cb

+ 2 - 2
app/src/main/java/com/itant/shibei/ui/home/goods/detail/GoodsDetailActivity.java

@@ -80,14 +80,14 @@ public class GoodsDetailActivity extends BaseBeiActivity implements View.OnClick
 
 
         rv_detail = findViewById(R.id.rv_detail);
         rv_detail = findViewById(R.id.rv_detail);
         rv_detail.setLayoutManager(new LinearLayoutManager(this));
         rv_detail.setLayoutManager(new LinearLayoutManager(this));
-        mPhotoAdapter = new DetailImgAdapter(this, mPhotoUrlList);
         mPhotoUrlList.addAll(mGoodsBean.contentImageUrlList);
         mPhotoUrlList.addAll(mGoodsBean.contentImageUrlList);
+        mPhotoAdapter = new DetailImgAdapter(this, mPhotoUrlList);
         rv_detail.setAdapter(mPhotoAdapter);
         rv_detail.setAdapter(mPhotoAdapter);
 
 
         rv_magnet = findViewById(R.id.rv_magnet);
         rv_magnet = findViewById(R.id.rv_magnet);
         rv_magnet.setLayoutManager(new LinearLayoutManager(this));
         rv_magnet.setLayoutManager(new LinearLayoutManager(this));
-        mMagnetAdapter = new MagnetAdapter(this, mMagnetList);
         mMagnetList.addAll(mGoodsBean.magnetBeanList);
         mMagnetList.addAll(mGoodsBean.magnetBeanList);
+        mMagnetAdapter = new MagnetAdapter(this, mMagnetList);
         rv_magnet.setAdapter(mMagnetAdapter);
         rv_magnet.setAdapter(mMagnetAdapter);
 
 
         tv_title.setText(mGoodsBean.title);
         tv_title.setText(mGoodsBean.title);

+ 13 - 15
app/src/main/res/layout/activity_goods_detail.xml

@@ -8,8 +8,9 @@
 
 
     <include layout="@layout/view_toolbar" />
     <include layout="@layout/view_toolbar" />
 
 
-
-    <ScrollView
+    <!--不要使用ScrollView嵌套RecyclerView,会导致显示不全。
+    要使用NestedScrollView嵌套RecyclerView,配合android:nestedScrollingEnabled="false"属性解决滑动冲突问题-->
+    <androidx.core.widget.NestedScrollView
         android:layout_width="match_parent"
         android:layout_width="match_parent"
         android:layout_height="wrap_content">
         android:layout_height="wrap_content">
 
 
@@ -18,15 +19,15 @@
             android:layout_height="wrap_content"
             android:layout_height="wrap_content"
             android:gravity="center_vertical"
             android:gravity="center_vertical"
             android:orientation="vertical"
             android:orientation="vertical"
-            android:paddingStart="@dimen/margin_default"
-            android:paddingEnd="@dimen/margin_default">
+            android:paddingStart="@dimen/margin_s"
+            android:paddingEnd="@dimen/margin_s">
 
 
             <!--标题-->
             <!--标题-->
             <TextView
             <TextView
                 android:id="@+id/tv_title"
                 android:id="@+id/tv_title"
                 android:layout_width="match_parent"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:layout_height="wrap_content"
-                android:layout_marginTop="@dimen/margin_default"
+                android:layout_marginTop="@dimen/margin_s"
                 android:textColor="@color/black"
                 android:textColor="@color/black"
                 android:textSize="@dimen/text_sub_title" />
                 android:textSize="@dimen/text_sub_title" />
 
 
@@ -66,24 +67,21 @@
                     android:textSize="@dimen/text_s" />
                     android:textSize="@dimen/text_s" />
             </LinearLayout>
             </LinearLayout>
 
 
-            <include layout="@layout/view_divider_slight"/>
-
-            <!--图片-->
             <androidx.recyclerview.widget.RecyclerView
             <androidx.recyclerview.widget.RecyclerView
-                android:id="@+id/rv_detail"
+                android:id="@+id/rv_magnet"
                 android:layout_width="match_parent"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:layout_height="wrap_content"
-                android:nestedScrollingEnabled="false"/>
+                android:nestedScrollingEnabled="false"
+                android:layout_marginBottom="@dimen/margin_default"/>
 
 
             <include layout="@layout/view_divider_slight"/>
             <include layout="@layout/view_divider_slight"/>
 
 
+            <!--图片-->
             <androidx.recyclerview.widget.RecyclerView
             <androidx.recyclerview.widget.RecyclerView
-                android:id="@+id/rv_magnet"
+                android:id="@+id/rv_detail"
                 android:layout_width="match_parent"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:layout_height="wrap_content"
-                android:nestedScrollingEnabled="false"
-                android:layout_marginTop="@dimen/margin_ss"
-                android:layout_marginBottom="@dimen/margin_ss"/>
+                android:nestedScrollingEnabled="false"/>
         </LinearLayout>
         </LinearLayout>
-    </ScrollView>
+    </androidx.core.widget.NestedScrollView>
 </LinearLayout>
 </LinearLayout>

+ 1 - 1
app/src/main/res/layout/item_goods_detail_img.xml

@@ -7,6 +7,6 @@
         android:id="@+id/iv_detail_img"
         android:id="@+id/iv_detail_img"
         android:layout_width="match_parent"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_height="wrap_content"
-        android:layout_marginBottom="@dimen/margin_sss"
+        android:layout_marginBottom="@dimen/margin_s"
         android:src="@mipmap/logo_gray"/>
         android:src="@mipmap/logo_gray"/>
 </FrameLayout>
 </FrameLayout>