desc:焦点控制

main
xiaowusky 2 years ago
parent 7d841697b6
commit b609fcdc1c

@ -2,11 +2,10 @@ package com.yinuo.safetywatcher.watcher.utils
import android.R
import android.content.Context
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.StateListDrawable
import android.view.View
import android.widget.Toast
import androidx.appcompat.content.res.AppCompatResources
import com.yinuo.safetywatcher.watcher.ui.view.CommonToast
fun Context.showToast(msg: String) {
@ -18,7 +17,10 @@ fun View?.trySetCommonBg() {
this?.apply {
val bg = StateListDrawable()
val currentBackground = this.background
val drawable = ColorDrawable(Color.RED)
val drawable = AppCompatResources.getDrawable(
this.context,
com.yinuo.safetywatcher.R.drawable.focus_bg
)
bg.addState(focusableStateKey, drawable)
bg.addState(intArrayOf(), currentBackground)
this.background = bg

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="@dimen/_20dp"/>
<solid android:color="#00000000"/>
<stroke android:color="@color/red" android:width="@dimen/_6dp"/>
</shape>
Loading…
Cancel
Save