XML
<com.youth.banner.Banner
android:id="@+id/banner"
android:layout_width="match_parent"
android:layout_height="170dp"
android:layout_marginLeft="17dp"
android:layout_marginTop="10dp"
android:layout_marginRight="17dp"
android:layout_marginBottom="10dp"
app:image_scale_type="fit_xy" />
JAVA
binding.banner.setOutlineProvider(new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
outline.setRoundRect(0,0,view.getWidth(),view.getHeight(), 30);
}
});
binding.banner.setClipToOutline(true);
如果設置了android:hardwareAccelerated=”false”以上方法都無效