代码之家  ›  专栏  ›  技术社区  ›  Prabhat

在Android 1.5中,屏幕键盘在QVGA800皮肤(分辨率)上覆盖了EditText。

  •  0
  • Prabhat  · 技术社区  · 16 年前

    在android 1.5sdk中,使用qvga800外观(分辨率),我在linearlayout中添加了8个edittext。当点击第8个编辑文本框时,屏幕显示。但是,布局没有向上移动足够的空间,我的意思是,它向上移动,但是它仍然包含正在键入的编辑文本框。如何解决这个问题?

    主要类别:

    package com.i;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.widget.EditText;
    
    public class myClass extends Activity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            EditText txt1=(EditText)findViewById(R.id.txt1);
            EditText txt2=(EditText)findViewById(R.id.txt2);
            EditText txt3=(EditText)findViewById(R.id.txt3);
            EditText txt4=(EditText)findViewById(R.id.txt4);
            EditText txt5=(EditText)findViewById(R.id.txt5);
            EditText txt6=(EditText)findViewById(R.id.txt6);
            EditText txt7=(EditText)findViewById(R.id.txt7);
            EditText txt8=(EditText)findViewById(R.id.txt8);
        }
    }
    

    MIN .XML:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
    <TextView  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/hello"
        />
        <EditText android:id="@+id/txt1" android:layout_width="fill_parent" android:layout_height="wrap_content"/>
        <EditText android:id="@+id/txt2" android:layout_width="fill_parent" android:layout_height="wrap_content"/>
        <EditText android:id="@+id/txt3" android:layout_width="fill_parent" android:layout_height="wrap_content"/>
        <EditText android:id="@+id/txt4" android:layout_width="fill_parent" android:layout_height="wrap_content"/>
        <EditText android:id="@+id/txt5" android:layout_width="fill_parent" android:layout_height="wrap_content"/>
        <EditText android:id="@+id/txt6" android:layout_width="fill_parent" android:layout_height="wrap_content"/>
        <EditText android:id="@+id/txt7" android:layout_width="fill_parent" android:layout_height="wrap_content"/>
        <EditText android:id="@+id/txt8" android:layout_width="fill_parent" android:layout_height="wrap_content"/>
    
    </LinearLayout>
    

    谢谢。

    1 回复  |  直到 16 年前
        1
  •  3
  •   infinitypanda    16 年前

    在滚动视图中将其全部包装。只需将main.xml更改为

    <?xml version="1.0" encoding="utf-8"?>
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
    <TextView  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/hello"
        />
        <EditText android:id="@+id/txt1" android:layout_width="fill_parent" android:layout_height="wrap_content"/>
        <EditText android:id="@+id/txt2" android:layout_width="fill_parent" android:layout_height="wrap_content"/>
        <EditText android:id="@+id/txt3" android:layout_width="fill_parent" android:layout_height="wrap_content"/>
        <EditText android:id="@+id/txt4" android:layout_width="fill_parent" android:layout_height="wrap_content"/>
        <EditText android:id="@+id/txt5" android:layout_width="fill_parent" android:layout_height="wrap_content"/>
        <EditText android:id="@+id/txt6" android:layout_width="fill_parent" android:layout_height="wrap_content"/>
        <EditText android:id="@+id/txt7" android:layout_width="fill_parent" android:layout_height="wrap_content"/>
        <EditText android:id="@+id/txt8" android:layout_width="fill_parent" android:layout_height="wrap_content"/>
    
    </LinearLayout>
    </ScrollView>