
点击下载 BGABannerDemo.apk 或扫描下面的二维码安装

maven { url 'https://jitpack.io' } 添加到 root build.gradle 的 repositories 中implementation 'androidx.legacy:legacy-support-v4:latestVersion'
implementation 'com.github.bingoogolapple:BGABanner-Android:latestVersion'
<cn.bingoogolapple.bgabanner.BGABanner
android:id="@+id/banner_guide_content"
style="@style/MatchMatch"
app:banner_pageChangeDuration="1000"
app:banner_pointAutoPlayAble="false"
app:banner_pointContainerBackground="@android:color/transparent"
app:banner_pointDrawable="@drawable/bga_banner_selector_point_hollow"
app:banner_pointTopBottomMargin="15dp"
app:banner_transitionEffect="alpha" />
有多种配置数据源的方式,这里仅列出三种方式。更多初始化方式请查看 demo
配置数据源的方式1:通过传入数据模型并结合 Adapter 的方式配置数据源。这种方式主要用于加载网络图片,以及实现少于3页时的无限轮播
mContentBanner.setAdapter(new BGABanner.Adapter<ImageView, String>() {
@Override
public void fillBannerItem(BGABanner banner, ImageView itemView, String model, int position) {
Glide.with(MainActivity.this)
.load(model)
.placeholder(R.drawable.holder)
.error(R.drawable.holder)
.centerCrop()
.dontAnimate()
.into(itemView);
}
});
mContentBanner.setData(Arrays.asList("网络图片路径1", "网络图片路径2", "网络图片路径3"), Arrays.asList("提示文字1", "提示文字2", "提示文字3"));
配置数据源的方式2:通过直接传入视图集合的方式配置数据源,主要用于自定义引导页每个页面布局的情况
List<View> views = new ArrayList<>();
views.add(View.inflate(context, R.layout.layout_guide_one, null));
views.add(View.inflate(context, R.layout.layout_guide_two, null));
views.add(View.inflate(context, R.layout.layout_guide_three, null));
mContentBanner.setData(views);
配置数据源的方式3:通过传入图片资源 id 的方式配置数据源,主要用于引导页每一页都是只显示图片的情况
// Bitmap 的宽高在 maxWidth maxHeight 和 minWidth minHeight 之间
BGALocalImageSize localImageSize = new BGALocalImageSize(720, 1280, 320, 640);
// 设置数据源
mContentBanner.setData(localImageSize, ImageView.ScaleType.CENTER_CROP,
R.drawable.uoko_guide_background_1,
R.drawable.uoko_guide_background_2,
R.drawable.uoko_guide_background_3);
mContentBanner.setDelegate(new BGABanner.Delegate<ImageView, String>() {
@Override
public void onBannerItemClick(BGABanner banner, ImageView itemView, String model, int position) {
Toast.makeText(banner.getContext(), "点击了" + position, Toast.LENGTH_SHORT).show();
}
});
mContentBanner.setEnterSkipViewIdAndDelegate(R.id.btn_guide_enter, R.id.tv_guide_skip, new BGABanner.GuideDelegate() {
@Override
public void onClickEnterOrSkip() {
startActivity(new Intent(GuideActivity.this, MainActivity.class));
finish();
}
});
<declare-styleable name="BGABanner">
<attr name="banner_pointContainerBackground" format="reference|color" />
<attr name="banner_pointDrawable" format="reference" />
<attr name="banner_pointContainerLeftRightPadding" format="dimension" />
<attr name="banner_pointTopBottomMargin" format="dimension" />
<attr name="banner_pointLeftRightMargin" format="dimension" />
<attr name="banner_indicatorGravity">
<flag name="top" value="0x30" />
<flag name="bottom" value="0x50" />
<flag name="left" value="0x03" />
<flag name="right" value="0x05" />
<flag name="center_horizontal" value="0x01" />
</attr>
<attr name="banner_pointAutoPlayAble" format="boolean" />
<attr name="banner_pointAutoPlayInterval" format="integer" />
<attr name="banner_pageChangeDuration" format="integer" />
<attr name="banner_transitionEffect" format="enum">
<enum name="defaultEffect" value="0" />
<enum name="alpha" value="1" />
<enum name="rotate" value="2" />
<enum name="cube" value="3" />
<enum name="flip" value="4" />
<enum name="accordion" value="5" />
<enum name="zoomFade" value="6" />
<enum name="fade" value="7" />
<enum name="zoomCenter" value="8" />
<enum name="zoomStack" value="9" />
<enum name="stack" value="10" />
<enum name="depth" value="11" />
<enum name="zoom" value="12" />
</attr>
<attr name="banner_tipTextColor" format="reference|color" />
<attr name="banner_tipTextSize" format="dimension" />
<attr name="banner_placeholderDrawable" format="reference" />
<attr name="banner_isNumberIndicator" format="boolean" />
<attr name="banner_numberIndicatorTextColor" format="reference|color" />
<attr name="banner_numberIndicatorTextSize" format="dimension" />
<attr name="banner_numberIndicatorBackground" format="reference" />
<attr name="banner_isNeedShowIndicatorOnOnlyOnePage" format="boolean" />
<attr name="banner_contentBottomMargin" format="dimension"/>
<attr name="banner_aspectRatio" format="float"/>
<attr name="android:scaleType"/>
</declare-styleable>
| 个人主页 | 邮箱 | BGA系列开源库QQ群 |
|---|---|---|
| bingoogolapple.cn | bingoogolapple@gmail.com | ![]() |
如果您觉得 BGA 系列开源库帮你节省了大量的开发时间,请扫描下方的二维码随意打赏,要是能打赏个 10.24 :monkey_face:就太:thumbsup:了。您的支持将鼓励我继续创作:octocat:
如果您目前正打算购买通往墙外的梯子,可以使用我的邀请码「YFQ9Q3B」购买 Lantern,双方都赠送三个月的专业版使用时间:beers:

Copyright 2015 bingoogolapple
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
$ claude mcp add BGABanner-Android \
-- python -m otcore.mcp_server <graph>