Java 键盘上推页脚
我的应用程序中有一个页脚,但我遇到了一个问题,每次键盘出来时页脚都会向上推。我已经将Java 键盘上推页脚,java,android,xml,keyboard,Java,Android,Xml,Keyboard,我的应用程序中有一个页脚,但我遇到了一个问题,每次键盘出来时页脚都会向上推。我已经将“android:windowSoftInputMode=“adjustPan”代码添加到我的清单文件中,但它没有修复它。 下面是隐藏键盘的常规视图 这是键盘可见时我的视图。我希望键盘覆盖页脚,而不是向上推 下面是我的布局代码 <android.support.design.widget.CoordinatorLayout android:layout_width="match_parent"
“android:windowSoftInputMode=“adjustPan”
代码添加到我的清单文件中,但它没有修复它。
下面是隐藏键盘的常规视图
这是键盘可见时我的视图。我希望键盘覆盖页脚,而不是向上推
下面是我的布局代码
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/myCoordinatorLayout"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout 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:id="@+id/icons_container"
tools:context=".app.LoginActivity">
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:id="@+id/toolBar">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/loginbannerimage"
android:contentDescription="banner"
android:layout_gravity="center_horizontal"/>
</android.support.v7.widget.Toolbar>
<ScrollView
android:id="@+id/login_form"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolBar">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- Login progress -->
<include layout="@layout/custom_progress_bar"/>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardUseCompatPadding="true"
app:cardElevation="3dp"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:cardBackgroundColor="@android:color/black"
android:layout_marginBottom="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardBackgroundColor="@color/toolBar"
app:cardCornerRadius="0dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Welcome To MAP"
android:textColor="@android:color/white"
android:textSize="20sp"
android:layout_gravity="center_horizontal"
android:padding="5dp"
android:gravity="center_horizontal" />
</android.support.v7.widget.CardView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardBackgroundColor="@color/cardBg"
app:cardCornerRadius="0dp"
android:padding="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="15dp">
<EditText
android:id="@+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Email here"
android:maxLines="1"
android:singleLine="true" />
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:imeActionLabel="Password here"
android:imeOptions="actionUnspecified"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true" />
<Button
android:id="@+id/email_sign_in_button"
style="?android:textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Sign-in"
android:textStyle="bold"
android:elevation="5dp"
android:textColor="@color/colorPrimaryDark"
android:background="@android:color/white"
android:layout_gravity="center_horizontal" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</ScrollView>
<include layout="@layout/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
</include>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
我认为这与scrollView有关,在scrollView中添加下面的行可能会解决这个问题 android:isScrollContainer=“false” 如前所述
这是因为页脚的高度值为
wrap_content
而另一部分(被压缩的部分)的值为
match_parent
如果它没有特定的值或包装内容,它将被压缩以适应键盘!或者您可以在滚动视图中使用它。这解决了我的问题
android:windowSoftInputMode="stateVisible|adjustPan"