【发布时间】:2019-10-16 23:16:34
【问题描述】:
当键盘出现时,我希望页脚随着键盘上升。
我尝试添加代码 android:windowSoftInputMode="adjustPan" ,android:windowSoftInputMode="adjustResize" 和 android:windowSoftInputMode="adjustResize|stateHidden" 到 manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:isScrollContainer="true"
>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/btCancel"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="left"
android:background="#FFFFFF"
android:text="@string/bt_cancel" />
</LinearLayout>
<EditText
android:layout_width="340dp"
android:layout_height="wrap_content"
android:layout_marginLeft="70dp"
android:background="#00000000"
android:gravity="top|left"
android:hint="@string/tv_comment"
android:inputType="textMultiLine"
android:maxLength="255"
android:maxLines="6"
android:textSize="20sp"
>
</EditText>
</LinearLayout>
</ScrollView>
<Button
style="?android:textAppearanceSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/action_sign_in_short"
android:layout_alignParentBottom="true"
android:textStyle="bold" />
我使代码更简单,但我认为它并不好。所以添加原始代码。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:isScrollContainer="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:id="@+id/btCancel"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="left"
android:background="#FFFFFF"
android:text="@string/bt_cancel" />
<Button
android:id="@+id/btContribution"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="left"
android:background="#FFFFFF"
android:text="@string/bt_contribution" />
<EditText
android:id="@+id/etComment"
android:layout_width="340dp"
android:layout_height="wrap_content"
android:layout_marginLeft="70dp"
android:background="#00000000"
android:gravity="top|left"
android:hint="@string/tv_comment"
android:inputType="textMultiLine"
android:maxLength="255"
android:maxLines="6"
android:textSize="20sp" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<Button
style="?android:textAppearanceSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="@string/action_sign_in_short"
android:textStyle="bold" />
</RelativeLayout>
【问题讨论】:
标签: android xml android-studio android-layout