【发布时间】:2019-08-20 14:51:28
【问题描述】:
有没有办法只在键盘上方移动某个布局而让其余部分保持不变?我曾尝试使用android:windowSoftInputMode="stateVisible|adjustResize" 并使用滚动视图,但它们都不起作用。
如果显示键盘,这就是它的外观,但我只需将键盘上方底部的注释布局移动,其余部分保持原样。
我的代码如下所示:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorWhite"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_weight="20"
android:layout_height="wrap_content"
android:id="@+id/scrollView">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorTransparent" android:id="@+id/toolbar_comments">
<ImageButton
android:layout_width="50dp"
android:layout_height="match_parent"
android:src="@drawable/ic_arrow_back"
android:tint="@android:color/black"
android:background="@color/colorTransparent" android:id="@+id/back_btn_comments"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textAlignment="center"
android:gravity="center"
android:textSize="20sp"
android:textColor="@android:color/black"
android:text="Kommentare"/>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_alignParentBottom="true"
android:background="@color/colorFont"/>
</RelativeLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/comments_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar_comments"
android:layout_marginTop="5dp">
</androidx.recyclerview.widget.RecyclerView>
</RelativeLayout>
</ScrollView>
<include
layout="@layout/message_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:layout_marginTop="5dp"/>
</LinearLayout>
感谢您的帮助!
【问题讨论】:
-
不幸的是不起作用