Android:键盘与EditText重叠(带有printscreens)

Android:键盘与EditText重叠(带有printscreens),第1张

概述我有一个EditText(用户可以输入数字), 所以当用户点击EditText文本框时,会打开一个带数字的键盘. 如您所见,键盘隐藏了文本框的一小部分. 但是当我按下一个键,例如0时,它看起来没问题. 有什么我可以做的(除了把EditText更高)所以它看起来像在第二张图片中? 编辑:.xml代码: <?xml version="1.0" encoding="utf-8"?><LinearLay 我有一个EditText(用户可以输入数字),
所以当用户点击EditText文本框时,会打开一个带数字的键盘.

如您所见,键盘隐藏了文本框的一小部分.

但是当我按下一个键,例如0时,它看起来没问题.

有什么我可以做的(除了把EditText更高)所以它看起来像在第二张图片中?

编辑:.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" androID:weightSum="1">    <relativeLayout androID:ID="@+ID/relativeLayout1" androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content">    <linearLayout androID:layout_wIDth="wrap_content" androID:orIEntation="vertical" androID:layout_height="wrap_content" androID:ID="@+ID/linearLayout1" androID:layout_alignParentBottom="true" androID:layout_alignParentleft="true" androID:layout_alignParenttop="true" androID:layout_alignParentRight="true">        <androID.Widget.CheckedTextVIEw androID:ID="@+ID/checkedTextVIEw1" androID:layout_height="wrap_content" androID:layout_wIDth="fill_parent" androID:textSize="17sp" androID:text="@string/toString"></androID.Widget.CheckedTextVIEw>        <autoCompleteTextVIEw androID:layout_height="wrap_content" androID:ID="@+ID/autoCompleteTextVIEw1" androID:layout_wIDth="fill_parent" androID:text="@string/emptyString" androID:textSize="17sp" androID:gravity="top|left" androID:minHeight="62dp">            <requestFocus></requestFocus>        </autoCompleteTextVIEw>        <linearLayout androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content" androID:ID="@+ID/linearLayout2">            <button androID:layout_height="wrap_content" androID:layout_wIDth="fill_parent" androID:layout_weight="0.33333333333" androID:text="@string/contactsstring" androID:textSize="17sp" androID:ID="@+ID/contactsbutton"></button>            <button androID:layout_weight="0.33333333333" androID:layout_height="wrap_content" androID:text="@string/groupsstring" androID:layout_wIDth="fill_parent" androID:ID="@+ID/groupsbutton" androID:textSize="17sp"></button>            <button androID:layout_weight="0.33333333333" androID:layout_height="wrap_content" androID:text="@string/favouritesstring" androID:layout_wIDth="fill_parent" androID:ID="@+ID/button3" androID:textSize="17sp"></button>        </linearLayout>        <TextVIEw androID:ID="@+ID/textVIEw1" androID:text="@string/messageString" androID:layout_height="wrap_content" androID:textSize="17sp" androID:layout_wIDth="fill_parent"></TextVIEw>        <EditText androID:layout_height="wrap_content" androID:ID="@+ID/editText1" androID:layout_wIDth="fill_parent" androID:gravity="top|left" androID:minHeight="105dp"></EditText>        <TextVIEw androID:ID="@+ID/textVIEw2" androID:text="@string/repetition" androID:layout_height="wrap_content" androID:layout_wIDth="fill_parent" androID:textSize="17sp"></TextVIEw>        <Spinner androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content" androID:ID="@+ID/spinner"></Spinner>        <linearLayout androID:layout_height="wrap_content" androID:ID="@+ID/linearLayout3" androID:layout_wIDth="fill_parent">            <ImageVIEw androID:src="@drawable/button_time" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:ID="@+ID/imageVIEw1" androID:layout_weight="0.1"></ImageVIEw>            <EditText androID:layout_height="wrap_content" androID:ID="@+ID/timeET" androID:inputType="number" androID:layout_wIDth="wrap_content" androID:layout_weight="0.4"></EditText>            <ImageVIEw androID:src="@drawable/button_date" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:ID="@+ID/imageVIEw2" androID:layout_weight="0.1"></ImageVIEw>            <EditText androID:layout_height="wrap_content" androID:ID="@+ID/dateET" androID:inputType="number" androID:layout_wIDth="wrap_content" androID:layout_weight="0.4" androID:layout_marginRight="3dp"></EditText>        </linearLayout>        <relativeLayout androID:ID="@+ID/relativeLayout2" androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent">            <linearLayout androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:ID="@+ID/linearLayout4" androID:layout_alignParentBottom="true" androID:layout_alignParentRight="true" androID:layout_alignParentleft="true">                <button androID:layout_weight="0.5" androID:layout_height="wrap_content" androID:text="@string/button_ok" androID:layout_wIDth="fill_parent" androID:ID="@+ID/button4" androID:textSize="17sp"></button>                <button androID:layout_height="wrap_content" androID:layout_wIDth="fill_parent" androID:ID="@+ID/button5" androID:layout_weight="0.5" androID:text="@string/button_cancel" androID:textSize="17sp"></button>            </linearLayout>        </relativeLayout>    </linearLayout></relativeLayout></linearLayout>
解决方法 我已经尝试过你的XML,是的,你说得对,问题就出现了.

为了解决这个问题,我在MainActivity.java中编写了这一行,希望对您有所帮助,并将布局XML放在ScrollVIEw中.

活动

public voID onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentVIEw(R.layout.temp);        getwindow().setSoftinputMode(WindowManager.LayoutParams.soFT_input_STATE_HIDDEN);        final EditText time = (EditText)findVIEwByID(R.ID.timeET);        time.setontouchListener(new OntouchListener() {            public boolean ontouch(VIEw v,MotionEvent event) {                time.requestLayout();                MyActivity.this.getwindow().setSoftinputMode(WindowManager.LayoutParams.soFT_input_ADJUST_UnspecIFIED);                return false;            }        });        final EditText date = (EditText)findVIEwByID(R.ID.dateET);        date.setontouchListener(new OntouchListener() {            public boolean ontouch(VIEw v,MotionEvent event) {                time.requestLayout();                MyActivity.this.getwindow().setSoftinputMode(WindowManager.LayoutParams.soFT_input_ADJUST_UnspecIFIED);                return false;            }        });         }

而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" >         <ScrollVIEw androID:ID="@+ID/scrollVIEw1"        androID:layout_height="fill_parent"         androID:layout_wIDth="fill_parent"         androID:weightSum="1">---------        </ScrollVIEw> </linearLayout>
总结

以上是内存溢出为你收集整理的Android:键盘与EditText重叠(带有printscreens)全部内容,希望文章能够帮你解决Android:键盘与EditText重叠(带有printscreens)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1138094.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-30
下一篇2022-05-30

发表评论

登录后才能评论

评论列表(0条)

    保存