Checkerboard background for transparency in zoomed images #92

Merged
AmineB merged 4 commits from davidoskky/ReaderForSelfoss-multiplatform:checkerboard into master 2022-11-11 19:29:43 +00:00
3 changed files with 2 additions and 17 deletions
Showing only changes of commit 3a3bf03114 - Show all commits

View File

@ -1,23 +1,18 @@
package bou.amine.apps.readerforselfossv2.android.fragments
import android.graphics.drawable.Drawable
import android.graphics.drawable.LayerDrawable
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import bou.amine.apps.readerforselfossv2.android.R
import bou.amine.apps.readerforselfossv2.android.databinding.FragmentImageBinding
import com.bumptech.glide.Glide
import com.bumptech.glide.request.target.ImageViewTarget
class ImageFragment : Fragment() {
private lateinit var imageUrl : String
private var _binding: FragmentImageBinding? = null
private val binding get() = _binding
private lateinit var layers: LayerDrawable
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@ -32,17 +27,7 @@ class ImageFragment : Fragment() {
binding!!.photoView.visibility = View.VISIBLE
Glide.with(activity)
.load(imageUrl)
.into(object : ImageViewTarget<Drawable>(binding!!.photoView) {
override fun setResource(resource: Drawable?) {
val background = resources.getDrawable(R.drawable.checkerboard, context?.theme)
layers = LayerDrawable(arrayOf(background, resource))
binding!!.photoView.setImageDrawable(layers)
}
override fun onLoadCleared(placeholder: Drawable?) {
layers = LayerDrawable(emptyArray())
}
})
.into(binding!!.photoView)
return view
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 B

View File

@ -10,7 +10,7 @@
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:adjustViewBounds="true"
android:background="?attr/colorOnBackground"
android:background="@drawable/checkerboard"
app:srcCompat="@android:drawable/screen_background_dark" />
</RelativeLayout>