这是我的代码
<?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
正在萎缩。
I used android:windowSoftInputMode="adjustPan"
在清单文件中,但通过使用它,它将推高整个活动的上侧,但我希望 ImageView 保持原样,当键盘打开时,ImageView 是从底部剪切的,而不是像中那样从顶部剪切的WhatsApp
应用。
任何帮助将不胜感激。谢谢 ..
我遇到了类似的问题,其中自定义视图 -ParallaxBackground
- 我改编的应该充当背景图像,具有由滚动驱动的视差效果ViewPager
在同一个活动中。
换句话说,我有一个视图,它显示宽度略大于屏幕的图像,并且当用户沿着视图滚动时ViewPager
,图像中ParallaxBackground
也滚动一点。
现在就我而言,我的 ViewPager 片段中有一些 EditText,当用户单击它们时,导致软键盘显示,ParallaxBackground(以及因此背景图像)将被重新调整大小并squeezed“违背我的意愿”。
所以我添加了一个boolean isBackground
, two int
s for fixedWidth
and 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
真实并给予fixedWidth
and fixedHeight
测量的屏幕宽度和高度的值。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)