android - 如何防止Android工具栏在键盘出现时向上移动

标签 android android-layout android-studio android-toolbar

我想防止应用栏在 Edittext 点击时向上推请帮助我防止应用栏滚动,我添加了 android:windowSoftInputMode="adjustResize"和 adjustmentpan 但不起作用,请帮助我。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:id="@+id/act"
android:clickable="true"
android:focusableInTouchMode="true"
android:orientation="vertical"
android:layout_height="match_parent"
tools:context="com.example.admin.easydart.View.Dart">
<android.support.v7.widget.Toolbar
    android:id="@+id/my_toolbar"
    android:layout_alignParentTop="true"
    android:background="#016ba9"
    android:layout_height="60dp"
    android:layout_width="match_parent">


</android.support.v7.widget.Toolbar>


<RelativeLayout
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:layout_below="@+id/my_toolbar"
    android:layout_height="match_parent">


        <LinearLayout
            android:id="@+id/actS"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginBottom="10dp"

            android:layout_marginTop="10dp"
            android:clickable="true"
            android:focusableInTouchMode="true"
            android:gravity="center"

            android:orientation="vertical">
            <ScrollView
                android:layout_width="match_parent"


                android:layout_height="match_parent">

最佳答案

在 Activity 类的 onCreate 方法中设置:

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);

关于android - 如何防止Android工具栏在键盘出现时向上移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49253743/

相关文章:

android - 在 android 中存储图像的最佳方式是什么?

android-studio - 如何禁用调用层次结构结果突出显示

linux - Linux 和 Windows 上的 Android Studio

android - Motion Layout Swipe 禁用点击 Youtube Player (Youtube Player API)

android - 将按钮对齐到屏幕的右下角?

java - 访问 postgresql 数据库时出现 NetworkOnMainThreadException

android - camera2,android中的手动对焦

android - 将位图设置为联系人图像

android - 从广播短信接收器更新谷歌地图标记

android - 如何将 ConstraintLayout 的子项放置在屏幕外(以便稍后可以将它们翻译到屏幕上)?