每当出现软键盘时,它都会调整背景图像的大小。请参考下面的截图:
如你所见,背景有点挤。有没有人能解释为什么背景会改变大小?
我的布局如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/page_bg"
android:isScrollContainer="false"
>
<LinearLayout android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_width="fill_parent"
>
<EditText android:id="@+id/CatName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="textCapSentences"
android:lines="1"
/>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/save"
android:onClick="saveCat"
/>
</LinearLayout>
<ImageButton
android:id="@+id/add_totalk"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:background="@null"
android:src="@drawable/add_small"
android:scaleType="center"
android:onClick="createToTalk"
android:layout_marginTop="5dp"
/>
</LinearLayout>
发布于 2010-11-27 15:04:43
好的,我用下面的命令修复了它
android:windowSoftInputMode="stateVisible|adjustPan"
manifest
文件中<Activity >
标记内的条目。我认为这是由于在活动中使用了ScrollView造成的。
发布于 2011-05-02 11:46:35
只是为了补充一下。
如果你在你的活动上有一个列表视图,你需要在你的列表视图属性中添加这个android:isScrollContainer="false"
...
不要忘记在您的活动中将android:windowSoftInputMode="adjustPan"
添加到您的清单xml中……
如果你们在布局中使用带有滚动视图的android:windowSoftInputMode="adjustUnspecified"
,那么你的背景仍然会被软键盘调整大小……
如果你使用"adjustPan“值来防止你的背景改变大小,那会更好。
发布于 2014-11-13 00:16:45
如果有人需要adjustResize
行为,并且不希望调整其ImageView
的大小,这里有另一个解决方法。
只需将ImageView
放入带有ScrollView.fillViewport = true
的ScrollView
=> RelativeLayout
中。
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:layout_width="100dp"
android:layout_height="100dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="@drawable/gift_checked" />
</FrameLayout>
</RelativeLayout>
</ScrollView>
https://stackoverflow.com/questions/4287473
复制相似问题