【问题标题】:adjustPan pushing my layout and hiding status baradjustPan 推送我的布局和隐藏状态栏
【发布时间】:2015-04-01 06:24:08
【问题描述】:

在清单中使用 adjustPan 会将我的布局推到顶部,并使我的 UI 看起来很荒谬。

这是我的 Android 清单:

<activity
        android:name=".AddNote"
        android:label="@string/title_activity_add_note"
        android:windowSoftInputMode="stateVisible|adjustPan">

这是我的 XML 文件:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.dinosaur.cwfei.materialnotes.AddNote">

<include
    android:id="@+id/app_bar"
    layout="@layout/app_bar_no_spinner" />

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="@dimen/cardview_margin">
        <ScrollView
            android:id="@+id/scroll_view"
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
          >
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="@dimen/activity_vertical_margin"
            android:orientation="vertical">

            <EditText

                android:id="@+id/editTextTitle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="@dimen/margin_16"
                android:background="@color/transparent"
                android:hint="@string/hint_title"
                android:textStyle="bold" />

            <EditText

                android:id="@+id/editTextDescription"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/transparent"
                android:hint="@string/hint_note" />

            <View
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_marginBottom="@dimen/margin_16"
                android:layout_marginTop="100dp"
                android:background="@color/divider_color" />

        </LinearLayout>
        </ScrollView>
    </android.support.v7.widget.CardView>

</LinearLayout>

【问题讨论】:

  • 你是怎么解决的?

标签: android window-soft-input-mode adjustpan


【解决方案1】:

通过使用adjustResize而不是adjustPan解决了这个问题,设置fitsSystemWindows="true"以防adjustResize不起作用。

【讨论】:

    【解决方案2】:

    在您的活动中使用android:windowSoftInputMode="adjustResize|adjustPan"。它应该可以正常工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-04-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多