Browse Source

1.添加点击空白隐藏输入法

20241218TB223FC(测试jar包)
wangwanlei 9 months ago
parent
commit
a1473b2fb5

+ 4
- 0
app/src/main/java/com/xhly/manageapp/ui/login/activity/LoginActivity.kt View File

92
                 viewModel.postPwdDetail(code,it)
92
                 viewModel.postPwdDetail(code,it)
93
             }
93
             }
94
         }
94
         }
95
+
96
+        mBinding.loginClayout.setOnClickListener {
97
+            hiddenSoft(mBinding.accountEt)
98
+        }
95
         onBackPressedDispatcher.addCallback {
99
         onBackPressedDispatcher.addCallback {
96
             //屏蔽返回
100
             //屏蔽返回
97
         }
101
         }

+ 1
- 0
app/src/main/res/layout/activity_login.xml View File

35
             android:layout_marginTop="72dp">
35
             android:layout_marginTop="72dp">
36
 
36
 
37
             <androidx.constraintlayout.widget.ConstraintLayout
37
             <androidx.constraintlayout.widget.ConstraintLayout
38
+                android:id="@+id/login_clayout"
38
                 android:layout_width="match_parent"
39
                 android:layout_width="match_parent"
39
                 android:layout_height="match_parent">
40
                 android:layout_height="match_parent">
40
 
41
 

+ 12
- 0
corelib/src/main/java/com/xhly/corelib/base/ui/BaseActivity.kt View File

2
 import android.os.Bundle
2
 import android.os.Bundle
3
 import android.util.Log
3
 import android.util.Log
4
 import android.view.Gravity
4
 import android.view.Gravity
5
+import android.view.inputmethod.InputMethodManager
6
+import android.widget.EditText
5
 import androidx.lifecycle.ViewModelProvider
7
 import androidx.lifecycle.ViewModelProvider
6
 import androidx.viewbinding.ViewBinding
8
 import androidx.viewbinding.ViewBinding
7
 import com.hjq.toast.Toaster
9
 import com.hjq.toast.Toaster
112
         super.onDestroy()
114
         super.onDestroy()
113
         EventBus.getDefault().unregister(this)
115
         EventBus.getDefault().unregister(this)
114
     }
116
     }
117
+
118
+    fun hiddenSoft(editText: EditText){
119
+        try {
120
+            val inputMethodManager = getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
121
+            // 隐藏输入法键盘
122
+            inputMethodManager.hideSoftInputFromWindow(editText.windowToken, 0)
123
+        }catch (e:Exception){
124
+
125
+        }
126
+    }
115
 }
127
 }

Loading…
Cancel
Save