ImageView的大小调整时,键盘打开
这是我的代码ImageView的大小调整时,键盘打开
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/bgImage"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:contentDescription="@string/todo"
android:scaleType="fitXY"
android:src="@drawable/default_wallpaper" />
<LinearLayout
android:id="@+id/mainLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/title"
android:orientation="vertical" >
<ListView
android:id="@+id/in"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@android:color/transparent"
android:cacheColorHint="@android:color/transparent"
android:divider="@android:color/transparent"
android:stackFromBottom="true"
android:transcriptMode="alwaysScroll" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="50dp"
android:orientation="horizontal" >
<EditText
android:id="@+id/edit_text_out"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_gravity="bottom"
android:layout_weight="1"
android:inputType="none" />
<Button
android:id="@+id/button_send"
android:layout_width="70dp"
android:layout_height="fill_parent"
android:text="@string/send"
android:textSize="15sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
在这个时候我EditText
软键盘上点击打开,但我ImageView
萎缩。
我在清单文件,但通过这一点,将推动整个活动的上侧用android:windowSoftInputMode="adjustPan"
但我想ImageView的,因为它是当键盘打开ImageView的是从底部不是从顶部切为WhatsApp
应用。
任何帮助会升值。谢谢..
删除父布局(RelativeLayout
)并使LinearLayout
仅包含对话框,父!再加上,加android:windowSoftInputMode="stateVisible|adjustResize"
到AndroidManifest.xml
我也有类似的问题,其中一个自定义视图 - ParallaxBackground
- 我已经适应应该由一个ViewPager
在滚动驱动的视差效果作为背景图片同样的活动。
换句话说,我有一个显示宽度比屏幕稍大的图像,当用户沿着ViewPager
滚动时,ParallaxBackground
中的图像也滚动一点。
现在在我的情况下,我的ViewPager的Fragments中有一些EditTexts,当用户点击它们,导致软键盘出现时,ParallaxBackground(因此,背景图像)将重新调整大小,并且“违背我的意愿”挤压。
所以我加了一个boolean isBackground
,二int
S表示fixedWidth
和fixedHeight
和不顾我查看的onMeasure()
像这样:
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if(isBackground)
// If this is being used as a background and is supposed to occupy the whole screen...
{
// force the View to have the specified dimensions
setMeasuredDimension(fixedWidth, fixedHeight);
}
// ...aply default measures...
else
{
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
我知道这是不是一个“美丽”的解决方案,但是,即使我的答案是不涉及您的问题100%,你可能想尝试扩展ImageView
类和压倒一切的onMeasure
。
然后,在你onCreate
方法,你可以设置isBackground
为true,并给予fixedWidth
和fixedHeight
为您测量屏幕宽度和高度的值。
那么如果我删除RelativeLayout的话,我怎样才能把ImageView的所有控件的背景是什么? – 2013-02-28 13:21:03