Android 显示键盘时线性布局不滚动
我面临ScrollView的问题。当键盘出现时,scrollview直到视图结束才滚动 以下是我的布局xml:Android 显示键盘时线性布局不滚动,android,android-layout,Android,Android Layout,我面临ScrollView的问题。当键盘出现时,scrollview直到视图结束才滚动 以下是我的布局xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android" android:layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:text="Add Member"
android:textColor="#FFF"
android:textSize="@dimen/heading_text_size"
android:background="@color/heading"
android:gravity="center"
android:padding="10dp"
android:layout_height="?attr/actionBarSize"/>
<ScrollView
android:layout_width="match_parent"
android:layout_alignParentTop="true"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content">
<EditText
android:id="@+id/search_member_number"
android:layout_width="match_parent"
android:hint="Enter mobile number"
android:layout_weight="3"
android:inputType="phone"
android:layout_marginLeft="10dp"
android:layout_gravity="center"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/searchExistingUserButton"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:text="Search"
android:textAllCaps="false"
android:background="#FF9800"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
</LinearLayout>
<EditText
android:id="@+id/txtUsername"
android:layout_width="match_parent"
android:layout_margin="10dp"
android:hint="Enter member name"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/txtAddress"
android:layout_width="match_parent"
android:hint="Address"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/txtEmail"
android:layout_width="match_parent"
android:hint="Email"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/txtContact"
android:layout_width="match_parent"
android:hint="Mobile No"
android:inputType="phone"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/txtReferredBy"
android:layout_width="match_parent"
android:hint="Referred by"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
<AutoCompleteTextView
android:id="@+id/txtKittyGroups"
android:layout_width="match_parent"
android:hint="Enter kitty group name"
android:layout_margin="10dp"
android:layout_weight="8"
android:layout_gravity="center"
android:textSize="@dimen/admin_setup_buttons_text_size"
android:textColor="#000"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/txtRepeat"
android:layout_width="match_parent"
android:hint="Enter repeat number"
android:layout_margin="10dp"
android:inputType="number"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/createUserButton"
android:layout_width="wrap_content"
android:layout_gravity="right"
android:text="Create Member"
android:textAllCaps="false"
android:background="#BBDEFB"
android:layout_margin="10dp"
android:padding="10dp"
android:layout_height="wrap_content"/>
</LinearLayout>
</ScrollView>
</LinearLayout>
我在stackoverflow中看到过几个帖子,但不幸的是没有一个是有效的。可能的解决办法是什么
提前谢谢。我想问题是由调整盘引起的。如果“调整平移”不调整窗口的大小,它将平移视图,以便任何具有焦点的对象都不会被软键盘遮挡 将此添加到您的AndroidManifest.xml中。这可能会奏效 例如:
<activity android:name="YourActivity"
android:windowSoftInputMode="adjustResize" />
在布局中使用此选项:
android:layout_marginBottom="16dp"
您需要添加
和
android:layout_height="100dp"
给出你想要的静态高度
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:text="Add Member"
android:textColor="#FFF"
android:textSize="@dimen/heading_text_size"
android:background="@color/heading"
android:gravity="center"
android:padding="10dp"
android:layout_height="?attr/actionBarSize"/>
<ScrollView
android:layout_width="match_parent"
android:layout_alignParentTop="true"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content">
<EditText
android:id="@+id/search_member_number"
android:layout_width="match_parent"
android:hint="Enter mobile number"
android:layout_weight="3"
android:inputType="phone"
android:layout_marginLeft="10dp"
android:layout_gravity="center"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/searchExistingUserButton"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:text="Search"
android:textAllCaps="false"
android:background="#FF9800"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
</LinearLayout>
<EditText
android:id="@+id/txtUsername"
android:layout_width="match_parent"
android:layout_margin="10dp"
android:hint="Enter member name"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/txtAddress"
android:layout_width="match_parent"
android:hint="Address"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/txtEmail"
android:layout_width="match_parent"
android:hint="Email"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/txtContact"
android:layout_width="match_parent"
android:hint="Mobile No"
android:inputType="phone"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/txtReferredBy"
android:layout_width="match_parent"
android:hint="Referred by"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
<AutoCompleteTextView
android:id="@+id/txtKittyGroups"
android:layout_width="match_parent"
android:hint="Enter kitty group name"
android:layout_margin="10dp"
android:layout_weight="8"
android:layout_gravity="center"
android:textSize="@dimen/admin_setup_buttons_text_size"
android:textColor="#000"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/txtRepeat"
android:layout_width="match_parent"
android:hint="Enter repeat number"
android:layout_margin="10dp"
android:inputType="number"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/createUserButton"
android:layout_width="wrap_content"
android:layout_gravity="right"
android:text="Create Member"
android:textAllCaps="false"
android:background="#BBDEFB"
android:layout_margin="10dp"
android:padding="10dp"
android:layout_height="wrap_content"/>
<Space
android:layout_width="match_parent"
android:layout_height="100dp" />
</LinearLayout>
</ScrollView>
</LinearLayout></LinearLayout>
尝试了这个。不幸的是,这并不能解决问题。当键盘打开时,当您尝试滚动到底部时,会发生什么情况??它会卡在特定的高度上吗?您是否尝试过从底部偏移布局并查看其是否有效??