Closed manondidi closed 5 years ago
ok,i use these code to make backgroundDrawable ` <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/cookie" android:layout_width="match_parent" android:layout_height="87dp">
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/publish_snack_success_bg"
/>
<LinearLayout
android:id="@+id/btnAction"
android:layout_width="55dp"
android:layout_height="26dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginRight="15dp"
android:layout_marginBottom="20dp"
android:background="@drawable/publish_snack_btn_bg"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="查看"
android:textColor="#ffffffff"
android:textSize="13sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:src="@drawable/publish_snack_arrow" />
</LinearLayout>
<TextView
android:id="@+id/tvTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@id/btnAction"
android:layout_alignBottom="@id/btnAction"
android:layout_marginLeft="16dp"
android:gravity="center_vertical"
android:text="发布成功"
android:textColor="#ffffffff"
android:textSize="16dp"
android:textStyle="bold" />
<FrameLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:visibility="gone">
<ImageView
android:id="@+id/iv_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/tv_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/btn_action"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</FrameLayout>
`
CookieBar.build(Smart.getApp().currentResumedActivity)
.setBackgroundColor(R.color.transparent_color)
.setCustomView(R.layout.layout_publish_fail_snackbar)
.setAnimationIn(R.anim.anim_top_snack_in, R.anim.anim_top_snack_in)
.setAnimationOut(R.anim.anim_top_snack_out, R.anim.anim_top_snack_out)
.setCustomViewInitializer {
val btnAction = it.findViewById
Thanks @manondidi , it is a bug.
In the next version I will make sure that in case of custom layout the default bg is not being applied.
in custom layout why i must have your define id?? if can not find just let it go
<FrameLayout android:layout_width="0dp" android:layout_height="0dp" android:visibility="gone">
<ImageView
android:id="@+id/iv_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/tv_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/btn_action"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
@manondidi
The issue has been raised before, future releases will not enforce 'cookie integrity' as being done currently, you can bypass the issue by adding the views you dont need and set their visibility to `View.GONE
Fixed background color override on custom layouts Removed cookie view integrity check for custom layout Changes made in the following commit
only find setBackgroundColor when i use setCustomView, if i set android:background="@drawable/publish_snack_success_bg" in my custom_layout.xml,its background will be setted by defaultbgcolor