Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
zhpanvip committed Apr 15, 2020
1 parent 62ab98c commit 3efdea0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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> {
Expand Down
4 changes: 3 additions & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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> {
Expand Down
Binary file modified app/release/app-release.apk
Binary file not shown.
4 changes: 2 additions & 2 deletions app/src/main/res/layout/item_new_type.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -22,6 +22,6 @@
android:paddingBottom="@dimen/dp_5"
android:text="多类型Item示例"
android:textColor="#fff"
android:textSize="16sp" />
android:textSize="@dimen/sp_26" />

</RelativeLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
/**
* <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 {
Expand Down

0 comments on commit 3efdea0

Please sign in to comment.