【问题标题】:ActionBar expand when enter text in EditText在 EditText 中输入文本时,ActionBar 展开
【发布时间】:2015-12-22 09:07:56
【问题描述】:

我有一个带有 Tabs 和 ViewPager 的片段。在 ViewPager 的片段中,我有一个 EditText,当我尝试输入文本时,ActionBar 已展开,我看不到 EditText。

这是带有 Tabs 和 ViewPager 的片段的布局:

<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">

<com.rey.material.widget.TabPageIndicator
    style="@style/TabPageIndicator"
    android:id="@+id/tabs"
    android:layout_height="@dimen/tabs_height"
    android:layout_width="match_parent"
    android:clipToPadding="false" />
<View
    android:id="@+id/shadow"
    android:layout_width="match_parent"
    android:layout_height="8dp"
    android:background="@drawable/shadow"
    android:layout_below="@+id/tabs"/>

<android.support.v4.view.ViewPager
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/shadow"/>

这是工具栏的代码:

<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/ToolBarStyle" android:layout_width="match_parent"
android:layout_height="wrap_content" android:background="?attr/colorPrimary"
android:minHeight="@dimen/abc_action_bar_default_height_material"
android:fitsSystemWindows="true"/>

这是 ToolBarStyle:

<style name="ToolBarStyle" parent="">
    <item name="android:elevation">@dimen/toolbar_elevation</item>
    <item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item>
    <item name="theme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
</style>

这可能是问题所在?

提前致谢。

【问题讨论】:

  • 你能发布完整的代码吗?
  • 可以添加xml包含收费条码吗?
  • 我在问题中添加了工具栏的代码和工具栏的样式。谢谢
  • 你能改变工具栏的高度吗?android:layout_height="@dimen/abc_action_bar_default_height_material"
  • android:layout_height="?actionBarSize" 到您的工具栏。

标签: android android-layout android-fragments android-actionbar android-edittext


【解决方案1】:

尝试将工具栏的setFitsSystemWindows设置为false

Toolbar toolbar = (Toolbar) findViewById(R.id.yourToolbar)
toolbar.setFitsSystemWindows(false);

或者您可以在 xml 中使用 fitsSystemWindows android.support.v7.widget.Toolbar 进行设置

android:fitsSystemWindows="false"

【讨论】:

    【解决方案2】:

    要启用adjustResize,请在活动的父布局中添加android:fitsSystemWindows="true"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-30
      • 2011-05-15
      • 1970-01-01
      相关资源
      最近更新 更多