先上图
在做之前,查了不少博客,都写的不够详细,也试了好几种:
(这部分为复制粘贴)
问题:一开始我用的相对布局,结果发现edittext 会被键盘所覆盖,本人也是菜鸡。开始了慢慢的解决道路。
1.发现在Manifest中
关键词 android:windowSoftInputMode。 !! !!!但是缺点 整体布局会压缩 或者看不到顶部 这不是我想要的。
2.继续百度后发现有人教用 :改用在AndroidMaifest.xml中使用的stateHidden|adjustResize,其中stateHidden是为了让首次进入页面是阻止软件盘的弹出,adjustResize是压缩布局。
用这种方法时,有一下注意事项:
a. 布局中必须有ListView或者ScrollView。
b. ListView或ScroolView中的属性layout_weight必须比较大。
c. ListView或ScroolView的属性layout_height一定要设置成wrap_content.
最终解决,在布局文件里完美搞定:
上布局文件xml:
android:layout_height="match_parent"
android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
android:id="@+id/re_aaa"
android:layout_marginBottom="50dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:id="@+id/title_bar"
app:left_button_visible="true"
app:title_text=""
app:title_text_color="@color/DarkGrey"
app:right_button_visible="false"
android:layout_width="match_parent"
android:layout_height="@dimen/title_heigh">
android:id="@+id/webview"
android:layout_below="@+id/title_bar"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#EEEEEE"
/>
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:gravity="center_vertical"
android:layout_gravity="bottom"
android:orientation="horizontal">
android:layout_width="22dp"
android:layout_height="22dp"
android:layout_marginStart="15dp"
android:src="@drawable/iv_collection" />
android:layout_width="match_parent"
android:layout_height="33dp"
android:layout_marginStart="15dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="15dp"
android:layout_marginBottom="8dp"
android:background="@drawable/bg_evaluation"
android:gravity="center_vertical"
android:orientation="horizontal">
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_marginStart="17dp"
android:src="@drawable/iv_print" />
android:id="@+id/et_evaluation"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="7dp"
android:hint="写评论..."
android:background="@null"
android:textColorHint="#333333"
android:textSize="13sp" />
注意:以上属性,别遗漏 android:fitsSystemWindows="true"
这就是完美解决方案。