久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Android:使用屏幕上的軟鍵盤(pán)僅調(diào)整部分視圖的大小

Android: Resize only parts of view with soft keyboard on screen(Android:使用屏幕上的軟鍵盤(pán)僅調(diào)整部分視圖的大小)
本文介紹了Android:使用屏幕上的軟鍵盤(pán)僅調(diào)整部分視圖的大小的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

我在 ImageView 頂部有一個(gè)帶有 Edittext 字段的視圖.當(dāng)鍵盤(pán)出現(xiàn)時(shí),我希望窗口調(diào)整大小,以便 EditText 不再被鍵盤(pán)隱藏.在 AndroidManifest 文件中,我聲明了 android:windowSoftInputMode="adjustResize" 并調(diào)整了屏幕大小,但問(wèn)題是我希望不調(diào)整 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 來(lái)擴(kuò)展一個(gè)額外的布局,還是調(diào)整大小仍然會(huì)影響它?

Could I inflate an additional layout with just the ImageView or will the resize still affect it?

推薦答案

完整的解決方案涉及幾個(gè)關(guān)鍵點(diǎn)

The full solution involves a few key points

  • 使用RelativeLayout,這樣Views可以設(shè)置成相互重疊
  • 使用 android:layout_alignParentBottom="true"
  • EditTextWindows 的底部對(duì)齊
  • 在您的清單中使用 android:windowSoftInputMode="adjustResize",以便在鍵盤(pán)彈出時(shí) Window 的底部會(huì)發(fā)生變化(如您所述)
  • ImageView放在一個(gè)ScrollView里面,這樣ImageView就可以比Window大,然后禁用使用 ScrollView#setEnabled(false)
  • ScrollView 上滾動(dòng)
  • 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>

這是我的活動(dòng)

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);
    }
}

我的安卓清單

<?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

這篇關(guān)于Android:使用屏幕上的軟鍵盤(pán)僅調(diào)整部分視圖的大小的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

EditText: Disable Paste/Replace menu pop-up on Text Selection Handler click event(EditText:禁用文本選擇處理程序單擊事件上的粘貼/替換菜單彈出)
Multiline EditText with Done SoftInput Action Label on 2.3(2.3 上帶有完成 SoftInput 操作標(biāo)簽的多行 EditText)
How to detect the swipe left or Right in Android?(如何在 Android 中檢測(cè)向左或向右滑動(dòng)?)
Prevent dialog dismissal on screen rotation in Android(防止在Android中的屏幕旋轉(zhuǎn)對(duì)話框解除)
How do I handle ImeOptions#39; done button click?(如何處理 ImeOptions 的完成按鈕點(diǎn)擊?)
How do you set EditText to only accept numeric values in Android?(您如何將 EditText 設(shè)置為僅接受 Android 中的數(shù)值?)
主站蜘蛛池模板: 久久久日韩精品一区二区三区 | 九九热这里只有精品6 | 欧美成人猛片aaaaaaa | 99精品国产一区二区三区 | 先锋资源站| 久久在线 | 综合色在线 | 国产亚洲精品久久久久久牛牛 | 一a一片一级一片啪啪 | 免费观看一区二区三区毛片 | 在线免费观看色 | 欧美日韩国产精品一区二区 | 欧美日韩视频 | 亚洲福利一区二区 | 日韩欧美国产成人一区二区 | 国产精品亚洲一区二区三区在线 | 97高清国语自产拍 | 最新免费视频 | 中文字幕精品视频在线观看 | 中文在线播放 | 久久新视频 | 国产激情一区二区三区 | 国产a区| 精品国产伦一区二区三区观看说明 | 欧美视频在线播放 | 国产精品无码永久免费888 | 在线观看av中文字幕 | 97精品一区二区 | 亚洲自拍偷拍视频 | 久热电影 | 羞羞视频免费在线观看 | 91久久精品国产91久久性色tv | 一区二区高清在线观看 | 欧美精品一区三区 | 中文字幕在线一区 | 精品亚洲一区二区三区 | 国产成人一区二 | 欧美精品片 | 日韩欧美国产一区二区 | 日韩精品免费在线观看 | 狠狠躁夜夜躁人人爽天天高潮 |