我有在一个ImageView的顶部的EDITTEXT领域的看法。当键盘出现我想要的窗口,调整大小,这样的EditText不再隐藏键盘。在AndroidManifest文件我宣布安卓windowSoftInputMode =adjustResize
键,屏幕大小,但问题是,我想ImageView的不被重新调整大小。
我怎样才能让ImageView的未受影响的?
I have a view with a Edittext field on top of an ImageView. When the keyboard comes up I want the window to resize so that EditText is no longer hidden by the keyboard. In the AndroidManifest file I declared android:windowSoftInputMode="adjustResize"
and the screen is resized but the issue is that I want the ImageView to not be re-sized.
How can I make the ImageView unaffected?
我可以吹一个额外的布局,只是ImageView的或将调整大小还是有影响吗?
Could I inflate an additional layout with just the ImageView or will the resize still affect it?
完整的解决方案涉及的几个要点。
The full solution involves a few key points
使用 RelativeLayout的
,使浏览
可以设置为彼此重叠
对齐的EditText
与的Windows
使用 Android的底部:layout_alignParentBottom =真正的
使用安卓windowSoftInputMode =adjustResize
在你的清单,让窗口底部
更改时键盘的弹出(如你提到的)
把的ImageView
在滚动型
,使的ImageView
可以比窗口
,并禁止使用滚动的滚动型
滚动型较大#setEnabled(假)
Use RelativeLayout
, so that Views
can be setup to overlap one another
Align the EditText
with the bottom of the Windows
using android:layout_alignParentBottom="true"
Use android:windowSoftInputMode="adjustResize"
in your manifest, so that the bottom of the Window
changes when the keyboard pops up (as you mentioned)
Put the ImageView
inside a ScrollView
so that the ImageView
can be larger than the Window
, and disable scrolling on the ScrollView
by using ScrollView#setEnabled(false)
下面是布局文件
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.so3.MainActivity">
<ScrollView
android:id="@+id/scroll"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/stickfigures"/>
</ScrollView>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@android:color/holo_blue_bright"
android:text="Please enter text"
android:textSize="40sp"
android:gravity="center_horizontal"/>
</RelativeLayout>
下面是我的活动
package com.so3;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ScrollView;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ScrollView sv = (ScrollView)findViewById(R.id.scroll);
sv.setEnabled(false);
}
}
我AndroidManifest
My AndroidManifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.so3" >
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.so3.MainActivity"
android:windowSoftInputMode="adjustResize"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
我的解决方案的屏幕截图
Screen shots of my solution