我是android api的初学者,我不想在键盘向上时缩放我的线性布局。就像在滚动视图中一样。这可能在xml中做到吗?谢谢你的帮助;-)
编辑:下面是我的xml代码:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:weightSum="10"
android:background="@drawable/bg_home"
android:gravity="center_vertical|center_horizontal">
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="8"
android:weightSum="7"
android:gravity="center_vertical|center_horizontal">
<ImageView
android:layout_width="match_parent"
android:layout_height="15dp"
android:layout_weight="1"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/logo"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="15dp"
android:layout_weight="1"/>
<EditText
android:layout_width="match_parent"
android:layout_height="30dp"
android:text="@string/login_label"
android:textColor="@color/gray"
android:background="@drawable/input"
/>
<ImageView
android:layout_width="match_parent"
android:layout_height="15dp"
android:layout_weight="1"/>
<EditText
android:layout_width="match_parent"
android:layout_height="30dp"
android:text="@string/password"
android:textColor="@color/gray"
android:background="@drawable/input"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="15dp"
android:layout_weight="1"/>
<Button
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@drawable/login_button"
android:text="@string/login"
android:textColor="@color/white"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="15dp"
android:layout_weight="1"/>
<Button
android:layout_width="match_parent"
android:layout_height="40dp"
android:text="@string/reminder"
android:textColor="@color/white"
android:background="@android:color/transparent"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="15dp"
android:layout_weight="1"/>
<Button
android:layout_width="200dp"
android:layout_height="55dp"
android:background="@drawable/register_button"
android:text="@string/register"
android:textColor="@color/white"
/>
<ImageView
android:layout_width="match_parent"
android:layout_height="15dp"
android:layout_weight="1"/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="60dp"
android:gravity="center_vertical|right">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/go"
android:textColor="@color/white"
android:background="@android:color/transparent"
android:gravity="center_vertical|right"
android:paddingRight="5dp"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="right"
android:textColor="@color/white"
android:src="@drawable/right"
android:adjustViewBounds="true"/>
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="15dp"
android:layout_weight="1"/>
</LinearLayout>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
</LinearLayout>
在你的AndroidManifest.xml文件中试试
android:windowSoftInputMode="adjustPan"
"adjustResize"活动的主窗口总是调整大小,为屏幕上的软键盘腾出空间。
"adjustPan"活动的主窗口没有调整大小为软键盘腾出空间。
把android:windowSoftInputMode="adjustNothing"或android:windowSoftInputMode="adjustPan"在你的manifest中的Activity
你正在寻找android:windowSoftInputMode,但它适用于整个Activity
。没有办法以类似的方式控制单独的ViewGroup
。
活动的主窗口如何与窗口交互包含屏幕软键盘。此属性的设置影响两件事:软键盘的状态-无论它是隐藏或可见——当活动成为用户关注的焦点时的关注。对活动的主窗口所做的调整——是否将其大小调整为较小,以便为软键盘腾出空间的一部分时,其内容平移使当前焦点可见窗口被软键盘覆盖。