SoftKey来自Edittext - Android

时间:2014-01-02 10:31:41

标签: android textbox keyboard

我正在开发一个Android应用程序。当焦点出现在EditText之一(在页面的下端)时,键盘会覆盖EditText,所以当我键入文本时,我看不到被键入的内容。我有什么选择?

如何在屏幕上更高的位置移动EditText?

我试过了 <activity name="YourActivity" android:windowSoftInputMode="stateVisible|adjustResize"> </activity>

<activity name="YourActivity"
android:windowSoftInputMode="stateVisible|adjustPan">

这是代码

FrameLayout container =  (FrameLayout) this.findViewById(R.id.Container);
    LayoutInflater mInflater = LayoutInflater.from(this);
    RelativeLayout setRelativeLayout = (RelativeLayout) mInflater.inflate(R.layout.layout_main, null);
    container.addView(setRelativeLayout);

这对我不起作用。

1 个答案:

答案 0 :(得分:0)

adjustResize和adjustPan不适合您的事实表明您的布局填满了屏幕,Android无法调整它以为键盘腾出空间。但是,如果您的布局包含在滚动视图中,则可能会解决问题。

您目前正在对RelativeLayout进行充气并将其添加到FrameLayout。我建议您尝试创建ScrollView,向其添加RelativeLayout,然后将ScrollView添加到FrameLayout:

FrameLayout container =  (FrameLayout) this.findViewById(R.id.Container);
LayoutInflater mInflater = LayoutInflater.from(this);
RelativeLayout setRelativeLayout = (RelativeLayout) mInflater.inflate(R.layout.layout_main, null);
ScrollView sv = new ScrollView(this);
sv.addView(setRelativeLayout);
container.addView(sv);