在 RelativeLayout/ConstraintLayout 中用 layout_above、marginBottom 強行疊加,極易因輸入法彈出、文字長度變化導致錯位。
FrameLayout 容器,內部包含 AutoCompleteTextView 和 ImageView(如下拉箭頭/清除圖標)。android:drawableEnd / drawableRight 直接在 AutoCompleteTextView 內部顯示圖標(最簡單)。
class CustomAutoComplete extends FrameLayout 封裝邏輯。將圖標作為輸入框的組成部分(drawable 或 內嵌子 View),而非獨立浮動 View,由佈局系統自動處理位置與適配。