Solve the problem of moving up the specified content in the Android soft keyboard pop-up layout

During the development of the company, I encountered multiple EditText input boxes. Some models on the android phone appeared to have clicked EditView. It gained the focus and the soft keyboard popped up. However , after retracting the soft keyboard and clicking on the EditView again, it will appear that it is blocked by the soft keyboard. In case, after clicking another EditView, the EditView returns to normal and is no longer obscured.

solve:

  1. Nest a ScrollView for the content that you want to be topped:
<ScrollView
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:scrollbars="none" 
    >
    
    …… 想要被顶上去的内容 ……
    
</ScrollView>
   2. Write immediately after the setContentView method in the onCreate event handler of Activity
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);


Guess you like

Origin blog.csdn.net/xufei5789651/article/details/55264210