Issue
I got unnecessary white background with square box while loading with Glide.
Below are the code
<ImageView
android:id="@+id/ivLogo"
android:layout_width="100dp"
android:layout_height="100dp"
android:contentDescription="@string/loading"
android:gravity="center"
android:src="@drawable/bg_loader"/>
Below is the fragment that loading the image : class LoaderFragment(private val msg:String?) : DialogFragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val v = LayoutInflater.from(context)
.inflate(R.layout.dialog_waiting,container,false)
val ivLogo = v.findViewById<ImageView>(R.id.ivLogo)
Glide.with(this).load(R.drawable.bg_loader_te)
.fitCenter()
.apply(
RequestOptions().placeholder(R.drawable.bg_loader_te)
.centerCrop()
)
.into(ivLogo)
return v
}
override fun onAttach(context: Context) {
super.onAttach(context)
}
}
Here is the screenshot

Also I tried the below code
<ImageButton
android:id="@+id/ivLogo"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:scaleType="centerInside"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:background="?attr/selectableItemBackgroundBorderless"
android:src="@drawable/bg_loader"
tools:ignore="ContentDescription" />
Solution
I fixed this using the below code
this.dialog?.setCanceledOnTouchOutside(false) this.dialog?.setCancelable(false) this.dialog?.setOnKeyListener { dialog, keyCode, event -> keyCode == KeyEvent.KEYCODE_BACK } this.dialog?.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
Answered By - Greeshma S
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.