【问题标题】:BottomNavigationView goes up when keyboard appears当键盘出现时,BottomNavigationView 上升
【发布时间】:2017-03-08 15:10:32
【问题描述】:

Image

我的 BottomNavigationView 工作正常,但是当我按下 EditText 写字时它会上升。上面的链接上有一张图片。

这是我的清单,其中包含了android:windowSoftInputMode="adjustPan",但它对我不起作用。还有其他建议吗?

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity"
        android:windowSoftInputMode="adjustPan">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

我的 xml 文件:

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:design="http://schemas.android.com/apk/res-auto"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.segunfamisa.sample.bottomnav.MainActivity">

    <android.support.v7.widget.Toolbar
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:id="@+id/mainToolbar"
        android:background="#ffffff"
        android:titleTextColor="#ffffff">
    </android.support.v7.widget.Toolbar>

    <View
        android:layout_width="match_parent"
        android:layout_height="2dp"
        android:background="@drawable/shadow_top"/>

    <FrameLayout
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:background="#ffffff">

    </FrameLayout>

    <View
        android:layout_width="match_parent"
        android:layout_height="2dp"
        android:background="@drawable/shadow"/>

    <android.support.design.widget.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        design:menu="@menu/bottom_nav_items"
        design:itemIconTint="@drawable/selector"
        design:itemTextColor="@drawable/selector"
        android:background="#000000" />
</LinearLayout>

【问题讨论】:

  • 您需要使用CoordinatorLayout
  • 找到解决方案了吗?
  • 我在 windowSoftInputMode (manifest) 上使用了调整大小,还添加了 getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);在我的 MainActivity @FelipeA 上。
  • @MatiasNagore,我做了同样的事情,而且工作得像个魅力!

标签: android bottomnavigationview


【解决方案1】:

在您的AndroidManifest.xml 中,将以下android:windowSoftInputMode="adjustPan" 添加到包含BottomNavigationView 的活动中

【讨论】:

    【解决方案2】:

    您只需像这样在清单中添加此代码..

     <activity android:name=".MainActivity"
            android:windowSoftInputMode="adjustPan">
    

    这对我有用..快乐编码

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-07-21
      • 1970-01-01
      • 2019-01-21
      • 1970-01-01
      • 2014-08-20
      • 2012-07-02
      • 2011-12-18
      • 1970-01-01
      相关资源
      最近更新 更多