parent
043a3bbe9c
commit
d402707531
|
@ -0,0 +1,21 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix.home
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import androidx.appcompat.widget.AppCompatImageView
|
||||
|
||||
class ImageViewTopCrop(context: Context, attrs: AttributeSet) : AppCompatImageView(context, attrs) {
|
||||
override fun setFrame(l: Int, t: Int, r: Int, b: Int): Boolean {
|
||||
val scaleFactor = width / drawable.intrinsicWidth.toFloat()
|
||||
val matrix = imageMatrix
|
||||
|
||||
matrix.setScale(scaleFactor, scaleFactor, 0f, 0f)
|
||||
imageMatrix = matrix
|
||||
|
||||
return super.setFrame(l, t, r, b)
|
||||
}
|
||||
}
|
|
@ -60,7 +60,7 @@
|
|||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/text_url" />
|
||||
|
||||
<ImageView
|
||||
<org.mozilla.fenix.home.ImageViewTopCrop
|
||||
android:id="@+id/tab_background"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="100dp"
|
||||
|
@ -68,7 +68,7 @@
|
|||
android:adjustViewBounds="false"
|
||||
android:focusable="false"
|
||||
android:importantForAccessibility="no"
|
||||
android:scaleType="centerCrop"
|
||||
android:scaleType="matrix"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
|
Loading…
Reference in New Issue