Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/388.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 底部导航视图随WindowsOfInputMode=adjustResize向上移动_Java_Android_Android Studio_Bottomnavigationview - Fatal编程技术网

Java 底部导航视图随WindowsOfInputMode=adjustResize向上移动

Java 底部导航视图随WindowsOfInputMode=adjustResize向上移动,java,android,android-studio,bottomnavigationview,Java,Android,Android Studio,Bottomnavigationview,我的布局需要WindowsOfInputMode=adjustRezise,以便我的按钮与键盘同步。但我不希望我的BottomNagivationView受此影响。 我怎样才能解决这样的问题 我的BottomNavigationView来自MainActivity.xml,它是: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schem

我的布局需要WindowsOfInputMode=adjustRezise,以便我的按钮与键盘同步。但我不希望我的BottomNagivationView受此影响。 我怎样才能解决这样的问题

我的BottomNavigationView来自MainActivity.xml,它是:

<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:layout_height="match_parent"
    tools:context=".MainActivity">

    <FrameLayout
        android:id="@+id/fragment_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/bottom_navigation"></FrameLayout>

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottom_navigation"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_alignParentBottom="true"
        app:menu="@menu/bottom_menu"/>


</RelativeLayout>
以下是一些图片,您可以理解我的意思:

因此,我想知道的是,如何将BottomNavigationView设置为在键盘打开时不执行任何操作,同时我希望我的按钮受到以下影响:
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT\u INPUT\u ADJUST\u RESIZE)

在我的例子中,只需在清单文件中添加以下行即可解决问题。
android:windowSoftInputMode=“adjustResize | adjustPan”

在我的例子中,只需在清单文件中添加以下行即可解决问题。
android:windowSoftInputMode=“adjustResize | adjustPan”

将活动标记内的android:windowSoftInputMode=“adjustPan”
添加到清单文件中。 然后转到活动,将父布局更改为RelativeLayout,然后创建框架布局,将片段保存在父布局的相对布局中。然后添加第二个布局,即LinearLayout,该布局包含bottomNavigationView,并使其高度和宽度与父级匹配,但位于FrameLayout下方。 下面是主要活动布局的示例

<?xml version="1.0" encoding="utf-8"?>
<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:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity">

//FrameLayout which holds all your fragments
<FrameLayout
    android:id="@+id/fragments_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">



</FrameLayout>


//BottomNavigationView Container
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:gravity="bottom"
    android:layout_below="@id/fragments_container">

    //BottomMenus
    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:id="@+id/bottom_navigation"
        android:background="@drawable/rectangle_4_dash"
        android:layout_alignParentBottom="true">

        //Container of Menus
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal"
            android:weightSum="5">

            //BottomMenu One
            <LinearLayout
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="match_parent"
                android:orientation="vertical"
                android:gravity="center_vertical">

                <ImageView
                    android:layout_width="20dp"
                    android:layout_height="20dp"
                    android:layout_gravity="center"
                    android:src="@drawable/home_icon" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="Home" />
            </LinearLayout>

             //BottomMenu Two
            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:gravity="center_vertical"
                android:orientation="vertical">

                <ImageView
                    android:layout_width="20dp"
                    android:layout_height="20dp"
                    android:layout_gravity="center"
                    android:src="@drawable/contact_icon" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="Contact" />
            </LinearLayout>


            //BottomMenu Three
            <LinearLayout
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="match_parent"
                android:orientation="vertical"
                android:gravity="center_vertical">

                <ImageView
                    android:layout_width="20dp"
                    android:layout_height="20dp"
                    android:layout_gravity="center"
                    android:src="@drawable/about_icon" />
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="About"
                    android:layout_gravity="center"/>
            </LinearLayout>

             //BottomMenu Four
            <LinearLayout
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="match_parent"
                android:orientation="vertical"
                android:gravity="center_vertical">

                <ImageView
                    android:layout_width="20dp"
                    android:layout_height="17dp"
                    android:layout_gravity="center"
                    android:src="@drawable/services_icon" />
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Services"
                    android:layout_gravity="center"/>
            </LinearLayout>

        </LinearLayout>


    </com.google.android.material.bottomnavigation.BottomNavigationView>
</LinearLayout>

//FrameLayout,用于保存所有片段
//BottomNavigationView容器
//底部菜单
//菜单容器
//底部菜单一
//底部菜单二
//底部菜单三
//底部菜单四

然后转到你想要滚动的片段,像下面的一样设计它

<?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:orientation="vertical">


<ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content">


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:text="Title Of Your Form"
                android:textAlignment="center"
                android:textColor="@color/black"
                android:textSize="18sp"
                android:textStyle="bold" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:padding="20dp">

                <EditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/f_name"
                    android:inputType="textPersonName"
                    android:padding="10dp"
                    android:textSize="14sp" />

                <EditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:hint="@string/m_name"
                    android:inputType="textPersonName"
                    android:padding="10dp"
                    android:textSize="14sp" />

                <EditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:hint="@string/l_name"
                    android:inputType="textPersonName"
                    android:padding="10dp"
                    android:textSize="14sp" />


                <EditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:hint="Message"
                    android:inputType="text"
                    android:padding="10dp"
                    android:textSize="14sp" />

            </LinearLayout>

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_marginTop="10dp"
                android:text="Send Messagge"
                android:textAllCaps="false"
                android:textColor="@color/white"
                android:layout_marginBottom="40dp"/>
        </LinearLayout>

</ScrollView>

我就是这样解决的,
如果您有任何疑问,请让我知道,但如果它有帮助或看起来是正确的答案,请将其标记为正确答案,谢谢。

将活动标记中的android:WindowsOfInputMode=“adjustPan”添加到清单文件中。 然后转到活动,将父布局更改为RelativeLayout,然后创建框架布局,将片段保存在父布局的相对布局中。然后添加第二个布局,即LinearLayout,该布局包含bottomNavigationView,并使其高度和宽度与父级匹配,但位于FrameLayout下方。 下面是主要活动布局的示例

<?xml version="1.0" encoding="utf-8"?>
<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:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity">

//FrameLayout which holds all your fragments
<FrameLayout
    android:id="@+id/fragments_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">



</FrameLayout>


//BottomNavigationView Container
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:gravity="bottom"
    android:layout_below="@id/fragments_container">

    //BottomMenus
    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:id="@+id/bottom_navigation"
        android:background="@drawable/rectangle_4_dash"
        android:layout_alignParentBottom="true">

        //Container of Menus
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal"
            android:weightSum="5">

            //BottomMenu One
            <LinearLayout
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="match_parent"
                android:orientation="vertical"
                android:gravity="center_vertical">

                <ImageView
                    android:layout_width="20dp"
                    android:layout_height="20dp"
                    android:layout_gravity="center"
                    android:src="@drawable/home_icon" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="Home" />
            </LinearLayout>

             //BottomMenu Two
            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:gravity="center_vertical"
                android:orientation="vertical">

                <ImageView
                    android:layout_width="20dp"
                    android:layout_height="20dp"
                    android:layout_gravity="center"
                    android:src="@drawable/contact_icon" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="Contact" />
            </LinearLayout>


            //BottomMenu Three
            <LinearLayout
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="match_parent"
                android:orientation="vertical"
                android:gravity="center_vertical">

                <ImageView
                    android:layout_width="20dp"
                    android:layout_height="20dp"
                    android:layout_gravity="center"
                    android:src="@drawable/about_icon" />
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="About"
                    android:layout_gravity="center"/>
            </LinearLayout>

             //BottomMenu Four
            <LinearLayout
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="match_parent"
                android:orientation="vertical"
                android:gravity="center_vertical">

                <ImageView
                    android:layout_width="20dp"
                    android:layout_height="17dp"
                    android:layout_gravity="center"
                    android:src="@drawable/services_icon" />
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Services"
                    android:layout_gravity="center"/>
            </LinearLayout>

        </LinearLayout>


    </com.google.android.material.bottomnavigation.BottomNavigationView>
</LinearLayout>

//FrameLayout,用于保存所有片段
//BottomNavigationView容器
//底部菜单
//菜单容器
//底部菜单一
//底部菜单二
//底部菜单三
//底部菜单四

然后转到你想要滚动的片段,像下面的一样设计它

<?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:orientation="vertical">


<ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content">


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:text="Title Of Your Form"
                android:textAlignment="center"
                android:textColor="@color/black"
                android:textSize="18sp"
                android:textStyle="bold" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:padding="20dp">

                <EditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/f_name"
                    android:inputType="textPersonName"
                    android:padding="10dp"
                    android:textSize="14sp" />

                <EditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:hint="@string/m_name"
                    android:inputType="textPersonName"
                    android:padding="10dp"
                    android:textSize="14sp" />

                <EditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:hint="@string/l_name"
                    android:inputType="textPersonName"
                    android:padding="10dp"
                    android:textSize="14sp" />


                <EditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:hint="Message"
                    android:inputType="text"
                    android:padding="10dp"
                    android:textSize="14sp" />

            </LinearLayout>

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_marginTop="10dp"
                android:text="Send Messagge"
                android:textAllCaps="false"
                android:textColor="@color/white"
                android:layout_marginBottom="40dp"/>
        </LinearLayout>

</ScrollView>

我就是这样解决的,
如果您有任何疑问,请让我知道,但如果它有帮助或看起来是正确的答案,请将其标记为正确答案,谢谢。

它没有帮助,我的想法是,我需要以某种方式使BottomNavigationView不受任何WindowsofInputMode模式的影响,或者将其设置为隐藏,但仅当它没有帮助时,我的想法是,我需要以某种方式使BottomNavigationView不受任何WindowsofInputMode模式的影响,或者将其设置为Hidden(隐藏),但仅针对它