安卓:调整的观点只有部分软键盘在屏幕上 [英] Android: Resize only parts of view with soft keyboard on screen

查看:206
本文介绍了安卓:调整的观点只有部分软键盘在屏幕上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有在一个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

这篇关于安卓:调整的观点只有部分软键盘在屏幕上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆