我不知道如何做到这一点.我将edittext的高度硬编码为基于目标设备的某些dp.我相信这必须改变.任何人都可以帮助我如何实现这一目标.
布局文件的XML和screencap一样
<?xml version="1.0" enCoding="utf-8"?><relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"androID:layout_wIDth="fill_parent"androID:layout_height="fill_parent"androID:background="#FFFFFF" ><linearLayout androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent" androID:orIEntation="vertical" > <EditText androID:ID="@+ID/EditMessage" androID:layout_wIDth="fill_parent" androID:layout_height="150dp" androID:background="@drawable/newback" androID:gravity="top" androID:imeOptions="actionDone" androID:inputType="textMultiline|textFilter|textVisiblePassword|textNoSuggestions" androID:maxLength="200" androID:padding="5dp" androID:textAppearance="?androID:attr/textAppearanceMedium" androID:textcolor="#000000" /> <linearLayout androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content" androID:gravity="center" androID:orIEntation="horizontal" > <button androID:ID="@+ID/PostMessage" androID:layout_wIDth="0dp" androID:layout_height="45dp" androID:layout_weight="1" androID:layout_marginRight="0.2dp" androID:background="@drawable/newbutton_corner" androID:text="@string/submitMessage" androID:textcolor="#FFFFFF" androID:textStyle="bold" /> <button androID:ID="@+ID/CancelMessage" androID:layout_wIDth="0dp" androID:layout_height="45dp" androID:layout_weight="1" androID:layout_marginRight="0.2dp" androID:background="@drawable/newbutton_corner" androID:text="@string/CancelMessage" androID:textcolor="#FFFFFF" androID:textStyle="bold" /> <button androID:ID="@+ID/DeleteMessage" androID:layout_wIDth="0dp" androID:layout_height="45dp" androID:layout_weight="1" androID:background="@drawable/newbutton_corner" androID:text="@string/DeleteMessage" androID:textcolor="#FFFFFF" androID:textStyle="bold" /> </linearLayout> </linearLayout></relativeLayout>解决方法 按如下方式更改EditText:
<EditText androID:ID="@+ID/EditMessage" androID:layout_wIDth="fill_parent" androID:layout_height="0dp" androID:layout_weight="1" androID:gravity="top" androID:imeOptions="actionDone" androID:inputType="textMultiline|textFilter|textVisiblePassword|textNoSuggestions" androID:maxLength="200" androID:padding="5dp" androID:textAppearance="?androID:attr/textAppearanceMedium" androID:textcolor="#000000" />
添加layout_weight = 1
在我看来,你不需要adjustPan.我会留给你决定.行为会有所不同,你可以尝试一下.以下是有关adjustPan的文档说明:
The activity’s main window is not resized to make room for the soft
keyboard. Rather,the contents of the window are automatically panned
so that the current focus is never obscured by the keyboard and users
can always see what they are tyPing. This is generally less desirable
than resizing,because the user may need to close the soft keyboard to
get at and interact with obscured parts of the window.
如果使用此按钮,底部的按钮可能会隐藏.而是使用adjustResize:
将此行放在AndroIDManifest中的活动中
androID:windowsoftinputMode="stateVisible|adjustResize"总结
以上是内存溢出为你收集整理的android – 基于键盘调整EditText高度全部内容,希望文章能够帮你解决android – 基于键盘调整EditText高度所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)