This is an interface for scanning code guns to enter the code content, which is often used in cash registers and other scenarios
I went through a lot of pitfalls in the early stage, and the online information also had various compatibility issues due to different Android historical versions. Finally, I summarized it.
Using the following scheme on Android devices without screen control can effectively avoid the problem of popping up the soft keyboard on the interface and displaying the top status bar. The environment is Android 7.1.2
Blocked soft keyboard: Autofocus inputType is set to none
Hide the top state: Solution 1hideStatusBar
Must be insetContentView
Previously, plan 2 was set in stylesNoActionBar
You can search for it yourself
<activity android:name=".MyActivity" android:windowSoftInputMode="stateHidden" android:exported="false" />
- activity_my.xml
<EditText android: android:layout_width="0dp" android:layout_height="0dp" android:focusable="true" android:focusableInTouchMode="true" android:focusedByDefault="true" android:importantForAutofill="no" android:inputType="none" />
class MyActivity : AppCompatActivity() { private lateinit var binding: ActivityMyBinding override fun onCreate(savedInstanceState: Bundle?) { (savedInstanceState) binding = (layoutInflater) hideStatusBar() setContentView() hideSoftKeyboard() } override fun onResume() { () hideSoftKeyboard() hideActionBar() } private fun hideSoftKeyboard() { (.SOFT_INPUT_STATE_HIDDEN) ?.let { view -> val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager imm?.hideSoftInputFromWindow(, InputMethodManager.RESULT_HIDDEN) } } private fun hideStatusBar() { requestWindowFeature(Window.FEATURE_NO_TITLE); ( .FLAG_FULLSCREEN, .FLAG_FULLSCREEN ) } private fun hideActionBar() { = View.SYSTEM_UI_FLAG_FULLSCREEN actionBar?.hide() } }
This is the article about blocking the soft keyboard and the top status bar when entering the Android QR code gun. This is all about this. For more related contents of the Android QR code blocking soft keyboard and the top status bar, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!