youth5201314 / banner

🔥🔥🔥Banner 2.0 来了!Android广告图片轮播控件,内部基于ViewPager2实现,Indicator和UI都可以自定义。
Apache License 2.0
12.87k stars 2.51k forks source link

2.0.2,当ScrollView或NestedScrollView上部有内容时,向上滚动banner使与之重合,banner图片切换后会有上一张图片的残留或闪烁问题,如下示例 #727

Closed fqingyang closed 4 years ago

fqingyang commented 4 years ago
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:id="@+id/text"
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:background="@android:color/background_light"
        android:text="测试测试" />
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <RelativeLayout

            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scrollbars="none">

            <TextView
                android:id="@+id/tip"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/indicator"
                android:layout_marginTop="10dp"
                android:gravity="center"
                android:text="下拉刷新重新设置数据数据,点击按钮改变使用场景" />

            <com.youth.banner.Banner xmlns:banner="http://schemas.android.com/apk/res-auto"
                android:id="@+id/banner"
                android:layout_width="match_parent"
                android:layout_height="180dp"
                android:layout_margin="10dp"
                banner:indicator_selected_color="@color/colorPrimary" />

            <com.youth.banner.indicator.RoundLinesIndicator
                android:id="@+id/indicator"
                android:layout_width="wrap_content"
                android:layout_height="20dp"
                android:layout_below="@+id/banner"
                android:layout_centerHorizontal="true"
                android:visibility="gone" />

            <Button
                android:id="@+id/style_image"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/tip"
                android:text="图片" />

            <Button
                android:id="@+id/style_image_title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/tip"
                android:layout_toRightOf="@id/style_image"
                android:text="图片+标题+指示器" />

            <Button
                android:id="@+id/style_image_title_num"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/tip"
                android:layout_toRightOf="@+id/style_image_title"
                android:text="图片+标题+数字" />

            <Button
                android:id="@+id/style_multiple"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/style_image"
                android:text="多类型UI" />

            <Button
                android:id="@+id/style_net_image"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/style_image"
                android:layout_toRightOf="@+id/style_multiple"
                android:text="网络图片" />

            <Button
                android:id="@+id/change_indicator"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/style_image"
                android:layout_toRightOf="@+id/style_net_image"
                android:text="外部指示器用法" />

            <TextView
                android:id="@+id/tip2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/style_multiple"
                android:gravity="center"
                android:text="更多使用场景" />

            <RelativeLayout
                android:id="@+id/topLine"
                android:layout_width="match_parent"
                android:layout_height="65dp"
                android:layout_below="@+id/tip2"
                android:layout_margin="5dp"
                android:background="#ffffff"
                android:orientation="horizontal"
                android:paddingTop="10dp"
                android:paddingBottom="10dp">

                <ImageView
                    android:id="@+id/image_top"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="10dp"
                    android:layout_marginRight="10dp"
                    android:src="@drawable/home_hotpoint" />

                <com.youth.banner.Banner
                    android:id="@+id/banner2"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_toLeftOf="@+id/image_right"
                    android:layout_toRightOf="@+id/image_top" />

                <ImageView
                    android:id="@+id/image_right"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="10dp"
                    android:layout_marginRight="10dp"
                    android:src="@drawable/home_right_arrow" />
            </RelativeLayout>

            <Button
                android:id="@+id/rv_banner"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/topLine"
                android:text="RecyclerView嵌套banner"
                android:textAllCaps="false" />

            <Button
                android:id="@+id/cl_banner"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/rv_banner"
                android:text="ConstraintLayout嵌套banner"
                android:textAllCaps="false" />

            <Button
                android:id="@+id/vp_banner"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/cl_banner"
                android:text="viewpaer2+fragment+RecyclerView嵌套banner"
                android:textAllCaps="false" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="500dp"
                android:layout_below="@+id/vp_banner"
                android:text="测试测试" />
        </RelativeLayout>
    </ScrollView>
</LinearLayout>
fqingyang commented 4 years ago

还没有找到原因,,目前暂时给上部TextView设置了一个elevation属性

fqingyang commented 4 years ago

如图 S00407-15062443 S00407-15063457

youth5201314 commented 4 years ago

好的,我看看

fqingyang commented 4 years ago

@多谢,辛苦了,新版本更易实现个性化效果,另外对RectangleIndicator选中时长度不一样的实现,您有什么实现思路吗

youth5201314 commented 4 years ago

这个关于指示器你可以全部自定义实现的,内置的只是比较常见的,后面会再完善这块,提供更多的效果。内置的RectangleIndicator,我只使用了normalwidth,没有用到selectedwidth,你在实现时可以使用到selectedwidth属性 或者在选中时将长度加长一点重写计算坐标绘制就行了。我更多是希望大家都能去自定义,然后把更多好的效果加到库里面,我个人的精力实在有限不能面面俱到,只能抽空余时间来完善的!

fqingyang commented 4 years ago

I see , Thank you !

youth5201314 commented 4 years ago

已经发现了问题所在,是绘制圆角造成的问题,你先去掉圆角,我下个版本修改下!

fqingyang commented 4 years ago

非常感谢!