Far*_*C K 6 android android-layout android-softkeyboard android-xml android-studio
我有一个布局,代码如下
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<!--some stuff here-->
<LinearLayout
android:id="@+id/layout1"
android:layout_alignParentBottom="true"
android:layout_above="@+id/layout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="5"
/>
<ImageButton
android:layout_width="50dp"
android:layout_height="50dp"
android:scaleType="fitStart"
android:layout_marginLeft="5dp"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:src="@drawable/ic_menu_send"/>
</LinearLayout>
<LinearLayout
android:id="@+id/layout2"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<!--some stuff here-->
</LinearLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
在上面的代码时,键盘秀,我想layout2留在bottom并layout1到go up with keyboard.如果我添加android:windowSoftInputMode="adjustPan|adjustResize"两个布局保持在底部.请帮忙
你可以说这不行
android:windowSoftInputMode="adjustPan|adjustResize"
Run Code Online (Sandbox Code Playgroud)
只需更改它即可
android:windowSoftInputMode="stateHidden"
下面的布局中还有一件事
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<!--some stuff here-->
<LinearLayout
android:id="@+id/layout1"
android:layout_alignParentBottom="true"
android:layout_above="@+id/layout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="5"
/>
<ImageButton
android:layout_width="50dp"
android:layout_height="50dp"
android:scaleType="fitStart"
android:layout_marginLeft="5dp"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:src="@drawable/ic_menu_send"/>
</LinearLayout>
<LinearLayout
android:id="@+id/layout2"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@color/colorPrimary">
<!--some stuff here-->
</LinearLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
当您应用此属性android:layout_above="@+id/layout2"后,然后删除此属性,您就不需要它了。layout1LinearLayoutandroid:layout_alignParentBottom="true"
所以现在看起来像这样
<LinearLayout
android:id="@+id/layout1"
android:layout_above="@+id/layout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
Run Code Online (Sandbox Code Playgroud)
注意:我的付出是
background color为了specific height寻求LinearLayout 2您的理解。
输出 :
普通屏幕
键盘打开屏幕。
请参阅上图,我使Red Mark该属性产生了问题,否则一切正常。
| 归档时间: |
|
| 查看次数: |
2666 次 |
| 最近记录: |