Skip to content

Commit

Permalink
OCT banner 圆角增加从xml配置中获取的功能。
Browse files Browse the repository at this point in the history
  • Loading branch information
lvshaojun committed May 25, 2020
1 parent b369212 commit 0c309b2
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/src/main/java/com/test/banner/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected void onCreate(Bundle savedInstanceState) {
banner.setAdapter(adapter)//设置适配器
// .setCurrentItem(3,false)
.addBannerLifecycleObserver(this)//添加生命周期观察者
.setBannerRound(BannerUtils.dp2px(5))//圆角
// .setBannerRound(BannerUtils.dp2px(5))//圆角
// .addPageTransformer(new RotateYTransformer())//添加切换效果
.setIndicator(new CircleIndicator(this))//设置指示器
.addOnPageChangeListener(this)//添加切换监听
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
android:layout_width="match_parent"
android:layout_height="180dp"
android:layout_margin="10dp"
banner:banner_radius="5dp"
banner:indicator_normal_color="@android:color/white"
banner:indicator_selected_color="@color/colorPrimary" />

Expand Down
1 change: 1 addition & 0 deletions banner/src/main/java/com/youth/banner/Banner.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ private void initTypedArray(@NonNull Context context, @NonNull AttributeSet attr
return;
}
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Banner);
mBannerRadius = a.getDimensionPixelSize(R.styleable.Banner_banner_radius, 0);
mDelayTime = a.getInt(R.styleable.Banner_delay_time, BannerConfig.LOOP_TIME);
mIsAutoLoop = a.getBoolean(R.styleable.Banner_is_auto_loop, BannerConfig.IS_AUTO_LOOP);
mIsInfiniteLoop = a.getBoolean(R.styleable.Banner_is_infinite_loop, BannerConfig.IS_INFINITE_LOOP);
Expand Down
1 change: 1 addition & 0 deletions banner/src/main/res/values/attr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<enum name="horizontal" value="0" />
<enum name="vertical" value="1" />
</attr>
<attr name="banner_radius" format="dimension"/>

</declare-styleable>
</resources>

0 comments on commit 0c309b2

Please sign in to comment.