Adding attribute to control alpha of the banner background
This commit is contained in:
parent
732582b6fe
commit
5e59eb474a
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<declare-styleable name="LocationLiveEndedBannerView">
|
||||
<attr name="locLiveEndedBkgWithAlpha" format="boolean" />
|
||||
</declare-styleable>
|
||||
|
||||
</resources>
|
|
@ -17,9 +17,11 @@
|
|||
package im.vector.app.features.location.live
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.TypedArray
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import im.vector.app.R
|
||||
import im.vector.app.databinding.ViewLocationLiveEndedBannerBinding
|
||||
|
||||
class LocationLiveEndedBannerView @JvmOverloads constructor(
|
||||
|
@ -28,10 +30,28 @@ class LocationLiveEndedBannerView @JvmOverloads constructor(
|
|||
defStyleAttr: Int = 0
|
||||
) : ConstraintLayout(context, attrs, defStyleAttr) {
|
||||
|
||||
private val binding = ViewLocationLiveEndedBannerBinding.inflate(
|
||||
LayoutInflater.from(context),
|
||||
this
|
||||
)
|
||||
|
||||
init {
|
||||
ViewLocationLiveEndedBannerBinding.inflate(
|
||||
LayoutInflater.from(context),
|
||||
this
|
||||
)
|
||||
context.theme.obtainStyledAttributes(
|
||||
attrs,
|
||||
R.styleable.LocationLiveEndedBannerView,
|
||||
0,
|
||||
0
|
||||
).run {
|
||||
try {
|
||||
setBackgroundAlpha(this)
|
||||
} finally {
|
||||
recycle()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setBackgroundAlpha(typedArray: TypedArray) {
|
||||
val withAlpha = typedArray.getBoolean(R.styleable.LocationLiveEndedBannerView_locLiveEndedBkgWithAlpha, false)
|
||||
binding.locationLiveEndedBannerBackground.alpha = if (withAlpha) 0.75f else 1f
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,8 @@
|
|||
android:layout_height="48dp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/locationLiveInactiveMap"
|
||||
app:layout_constraintEnd_toEndOf="@id/locationLiveInactiveMap"
|
||||
app:layout_constraintStart_toStartOf="@id/locationLiveInactiveMap" />
|
||||
app:layout_constraintStart_toStartOf="@id/locationLiveInactiveMap"
|
||||
app:locLiveEndedBkgWithAlpha="true" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/locationLiveInactiveIcon"
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
android:id="@+id/locationLiveEndedBannerBackground"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="48dp"
|
||||
android:alpha="0.75"
|
||||
android:src="?android:colorBackground"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
|
Loading…
Reference in New Issue