android:windowSoftInputMode="adjustResize|stateHidden" 已設定,但鍵盤彈出時 ScrollView 內容不滾動,底部被遮擋。
佈局結構中 ScrollView 為 RelativeLayout 直接子視圖,且未約束在底部 Button 上方。adjustResize 需要根佈局可縮放,但 RelativeLayout 高度固定 match_parent,導致縮放無效。
<RelativeLayout ...>
<Button
android:id="@+id/bottomBtn"
android:layout_alignParentBottom="true" ... />
<ScrollView
android:layout_above="@id/bottomBtn" // 關鍵:約束在 Button 上方
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true">
<!-- 內容 -->
</ScrollView>
</RelativeLayout>
ScrollView 加上 android:layout_above="@id/bottomBtn"id 並 alignParentBottomScrollView 高度用 wrap_content 或 match_parent 配合約束均可使用 ConstraintLayout 作為根佈局,配合 app:layout_constraintBottom_toTopOf="@id/bottomBtn" 更靈活。