我有一个EditText(用户可以键入数字的中) 因此,当用户点击的EditText文本框与数字键盘被打开。
你可以看到键盘隐藏文本框的一小部分。
但是,当我preSS的关键,例如,0,它看起来确定。
有什么我可以做(除了把EditText上更高),所以它会看起来像它在第二张照片?
编辑:将.xml code:
< XML版本=1.0编码=UTF-8&GT?;
<的LinearLayout
的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:方向=垂直
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT机器人:weightSum =1>
< RelativeLayout的机器人:ID =@ + ID / relativeLayout1机器人:layout_width =FILL_PARENT机器人:layout_height =WRAP_CONTENT>
< LinearLayout中的android:layout_width =WRAP_CONTENT机器人:方向=垂直机器人:layout_height =WRAP_CONTENT机器人:ID =@ + ID / linearLayout1机器人:layout_alignParentBottom =真正的机器人:layout_alignParentLeft =真正的机器人:layout_alignParentTop =真正的机器人:layout_alignParentRight =真正的>
< android.widget.CheckedTextView机器人:ID =@ + ID / checkedTextView1机器人:layout_height =WRAP_CONTENT机器人:layout_width =FILL_PARENT机器人:TEXTSIZE =17sp机器人:文本=@字符串/的toString&GT ;< /android.widget.CheckedTextView>
< AutoCompleteTextView安卓layout_height =WRAP_CONTENT机器人:ID =@ + ID / autoCompleteTextView1机器人:layout_width =FILL_PARENT机器人:文本=@字符串/ emptyString机器人:TEXTSIZE =17sp安卓重力=顶部|左机器人:=了minHeight62dp>
< requestFocus的>< / requestFocus的>
< / AutoCompleteTextView>
< LinearLayout中的android:layout_width =FILL_PARENT机器人:layout_height =WRAP_CONTENT机器人:ID =@ + ID / linearLayout2>
<按钮机器人:layout_height =WRAP_CONTENT机器人:layout_width =FILL_PARENT机器人:layout_weight =0.33333333333机器人:文本=@字符串/ contactsString机器人:TEXTSIZE =17sp机器人:ID =@ + ID / contactsButton>< /按钮>
<按钮机器人:layout_weight =0.33333333333机器人:layout_height =WRAP_CONTENT机器人:文本=@字符串/ groupsString机器人:layout_width =FILL_PARENT机器人:ID =@ + ID / groupsButton机器人:TEXTSIZE = 17sp>< /按钮>
<按钮机器人:layout_weight =0.33333333333机器人:layout_height =WRAP_CONTENT机器人:文本=@字符串/ favouritesString机器人:layout_width =FILL_PARENT机器人:ID =@ + ID /按钮3机器人:TEXTSIZE = 17sp>< /按钮>
< / LinearLayout中>
< TextView的机器人:ID =@ + ID / textView1机器人:文本=@字符串/ messageString机器人:layout_height =WRAP_CONTENT机器人:TEXTSIZE =17sp机器人:layout_width =FILL_PARENT>< / TextView的>
< EditText上安卓layout_height =WRAP_CONTENT机器人:ID =@ + ID / editText1机器人:layout_width =FILL_PARENT安卓重力=顶|左安卓了minHeight =105dp>< /的EditText&GT ;
< TextView的机器人:ID =@ + ID / textView2机器人:文本=@字符串/重复机器人:layout_height =WRAP_CONTENT机器人:layout_width =FILL_PARENT机器人:TEXTSIZE =17sp>< / TextView的>
<微调的android:layout_width =FILL_PARENT机器人:layout_height =WRAP_CONTENT机器人:ID =@ + ID /微调>< /微调>
< LinearLayout中的android:layout_height =WRAP_CONTENT机器人:ID =@ + ID / linearLayout3机器人:layout_width =FILL_PARENT>
< ImageView的机器人:SRC =@可绘制/ button_time机器人:layout_width =WRAP_CONTENT机器人:layout_height =WRAP_CONTENT机器人:ID =@ + ID / imageView1机器人:layout_weight =0.1>< / ImageView的>
< EditText上安卓layout_height =WRAP_CONTENT机器人:ID =@ + ID / timeET机器人:inputType =号机器人:layout_width =WRAP_CONTENT机器人:layout_weight =0.4>< /的EditText>
< ImageView的机器人:SRC =@可绘制/ button_date机器人:layout_width =WRAP_CONTENT机器人:layout_height =WRAP_CONTENT机器人:ID =@ + ID / imageView2机器人:layout_weight =0.1>< / ImageView的>
< EditText上安卓layout_height =WRAP_CONTENT机器人:ID =@ + ID / dateET机器人:inputType =号机器人:layout_width =WRAP_CONTENT机器人:layout_weight =0.4的Android版本:layout_marginRight =3DP&GT ;< /的EditText>
< / LinearLayout中>
< RelativeLayout的机器人:ID =@ + ID / relativeLayout2机器人:layout_width =FILL_PARENT机器人:layout_height =FILL_PARENT>
< LinearLayout中的android:layout_width =WRAP_CONTENT机器人:layout_height =WRAP_CONTENT机器人:ID =@ + ID / linearLayout4机器人:layout_alignParentBottom =真正的机器人:layout_alignParentRight =真正的机器人:layout_alignParentLeft =真与GT ;
<按钮机器人:layout_weight =0.5的Android版本:layout_height =WRAP_CONTENT机器人:文本=@字符串/ button_ok机器人:layout_width =FILL_PARENT机器人:ID =@ + ID /将Button4机器人:TEXTSIZE = 17sp>< /按钮>
<按钮机器人:layout_height =WRAP_CONTENT机器人:layout_width =FILL_PARENT机器人:ID =@ + ID / button5机器人:layout_weight =0.5的Android版本:文本=@字符串/ button_cancel机器人:TEXTSIZE = 17sp>< /按钮>
< / LinearLayout中>
< / RelativeLayout的>
< / LinearLayout中>
< / RelativeLayout的>
< / LinearLayout中>
解决方案
我已经试过你的XML是的,你是对的问题发生。
为了解决我写这条线在我MainActivity.java希望这对您有所帮助的问题,并把布局XML,滚动型。的
活动
公共无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.temp);
。getWindow()setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
最后的EditText时间=(EditText上)findViewById(R.id.timeET);
time.setOnTouchListener(新OnTouchListener(){
公共布尔onTouch(视图V,MotionEvent事件){
time.requestLayout();
MyActivity.this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_UNSPECIFIED);
返回false;
}
});
最后的EditText日期=(EditText上)findViewById(R.id.dateET);
date.setOnTouchListener(新OnTouchListener(){
公共布尔onTouch(视图V,MotionEvent事件){
time.requestLayout();
MyActivity.this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_UNSPECIFIED);
返回false;
}
});
}
和 XML 是什么样子,
< XML版本=1.0编码=UTF-8&GT?;
<的LinearLayout
的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:方向=垂直
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT>
<滚动型机器人:ID =@ + ID / scrollView1
机器人:layout_height =FILL_PARENT
机器人:layout_width =FILL_PARENT
机器人:weightSum =1>
---
---
---
< /滚动型>
< / LinearLayout中>
I have an EditText (that the user can type numbers in), so when the user clicks on the EditText text box a keyboard with numbers is opened.
as you can see the keyboard hides a small part of the text box.
But when I press a key, for example, 0, it looks ok.
Is there anything I can do (besides putting the EditText higher) so it will looks like it does in the second picture?
Edit: the .xml code:
<?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>
解决方案
I have tried your XML and yes you are right the problem occur.
To solve the problem I have written this line in my MainActivity.java hope this help to you,And put the layout XML in ScrollView.
Activity
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;
}
});
}
And The XML is Like,
<?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>