adjustPan pushing my layout and hiding status bar

断了今生、忘了曾经 提交于 2020-01-03 15:38:21

问题


Using adjustPan in manifest pushes my layout to the top and makes my UI look ridiculous.

This is my Android manifest:

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

This is my XML file:

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

回答1:


Solved it by using adjustResize instead of adjustPan, set fitsSystemWindows="true" in case adjustResize was not working.




回答2:


Use android:windowSoftInputMode="adjustResize|adjustPan" in your activity. It should work fine.



来源:https://stackoverflow.com/questions/29384134/adjustpan-pushing-my-layout-and-hiding-status-bar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!