不錯的網址:自己的網盤裏有代碼
https://blog.csdn.net/smileiam/article/details/69055963
也可以使用系統的方法(這個有可能不對)
在activity的setContentView()前添加如下代碼:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
然後在清單文件中添加
android:windowSoftInputMode="stateAlwaysHidden|adjustPan"
第二種 --------
佈局嵌套 scrollVIew
<ScrollView android:fillViewport="true" android:scrollbars="none" android:layout_width="match_parent" android:layout_height="match_parent">
然後在清單文件中 Activity 中添加
android:windowSoftInputMode="stateAlwaysHidden|adjustResize"