Browse Source

Update README

zhpanvip 5 years ago
parent
commit
3efdea0e39

+ 3 - 1
README.md

@@ -163,7 +163,7 @@ implementation 'com.github.zhpanvip:BannerViewPager:latestVersion'
 ```
 
 ### 3.The item layout of banner:
-
+ **Attention:The layout width and height required "match_parent".Otherwise,the ViewPager2 will throws a IllegalStateException.**
 ```
     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="match_parent"
@@ -200,6 +200,8 @@ implementation 'com.github.zhpanvip:BannerViewPager:latestVersion'
 
 ### 4.Extends BaseViewHolder,and override methods.
 
+ **Attention:Don't use {@link RecyclerView.ViewHolder#getAdapterPosition} method to get position in ViewHolder,this method will return a fake position.**
+
 ```
     public class NetViewHolder extends BaseViewHolder<BannerData> {
 

+ 3 - 1
README_CN.md

@@ -161,7 +161,7 @@ implementation 'com.github.zhpanvip:BannerViewPager:latestVersion'
 ```
 
 ### 3.Banner的Item页面布局
-
+**注意:Item的布局必须是"match_parent",否则ViewPager2会抛出一个IllegalStateException.
 ```
     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="match_parent"
@@ -198,6 +198,8 @@ implementation 'com.github.zhpanvip:BannerViewPager:latestVersion'
 
 ### 4.继承BaseViewHolder,并重写相关方法
 
+**注意:在ViewHolder中不要用{@link RecyclerView.ViewHolder#getAdapterPosition} 方法获取position,这个方法会返回一个不正确的position**
+
 ```
     public class NetViewHolder extends BaseViewHolder<BannerData> {
 

BIN
app/release/app-release.apk


+ 2 - 2
app/src/main/res/layout/item_new_type.xml

@@ -7,13 +7,13 @@
         android:id="@+id/image_view"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
+        android:src="@drawable/bg_card3"
         android:scaleType="centerCrop" />
 
     <TextView
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_centerHorizontal="true"
-        android:background="@drawable/bg_start"
         android:gravity="center"
         android:paddingStart="@dimen/dp_10"
         android:paddingTop="@dimen/dp_5"
@@ -22,6 +22,6 @@
         android:paddingBottom="@dimen/dp_5"
         android:text="多类型Item示例"
         android:textColor="#fff"
-        android:textSize="16sp" />
+        android:textSize="@dimen/sp_26" />
 
 </RelativeLayout>

+ 2 - 1
bannerview/src/main/java/com/zhpan/bannerview/BaseViewHolder.java

@@ -15,7 +15,8 @@ import androidx.recyclerview.widget.RecyclerView;
 /**
  * <pre>
  *   Created by zhpan on 2020/4/5.
- *   Description:
+ *   Attention:Don't use {@link RecyclerView.ViewHolder#getAdapterPosition}
+ *   method to get position,this method will return a fake position.
  * </pre>
  */
 public abstract class BaseViewHolder<T> extends RecyclerView.ViewHolder {