本人项目中一个弹窗控件,需要在软键盘弹出后不遮挡底部控件!
效果:
直接上代码:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/dia_comment_ll" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="bottom" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="fill_parent" android:layout_weight="1"> <ScrollView android:layout_width="fill_parent" android:layout_height="wrap_content" android:fillViewport="true" android:orientation="vertical" android:scrollbars="vertical"> </ScrollView> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <EditText android:id="@+id/dia_comment_et" android:layout_width="match_parent" android:layout_height="175dp" android:layout_weight="1"/> <TextView android:id="@+id/dia_comment_tv" android:layout_width="120dp" android:layout_height="40dp" android:layout_weight="1"/> </LinearLayout> </LinearLayout>
第一个LinearLayout中的weight=1和scrollView是关键!