desc:焦点控制
							parent
							
								
									5421ad151c
								
							
						
					
					
						commit
						7565581995
					
				| @ -1,9 +1,26 @@ | ||||
| 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 com.yinuo.safetywatcher.watcher.ui.view.CommonToast | ||||
| 
 | ||||
| fun Context.showToast(msg: String) { | ||||
|     CommonToast(this).makeCommonText(this, msg, Toast.LENGTH_SHORT).show() | ||||
| } | ||||
| 
 | ||||
| private val focusableStateKey: IntArray = intArrayOf(R.attr.state_focused) | ||||
| fun View?.trySetCommonBg() { | ||||
|     this?.apply { | ||||
|         val bg = StateListDrawable() | ||||
|         val currentBackground = this.background | ||||
|         val drawable = ColorDrawable(Color.RED) | ||||
|         bg.addState(focusableStateKey, drawable) | ||||
|         bg.addState(intArrayOf(), currentBackground) | ||||
|         this.background = bg | ||||
|     } | ||||
| } | ||||
					Loading…
					
					
				
		Reference in New Issue