如何在弹出软键盘时使聚焦的 EditText 可见?
我正在尝试制作一个布局内内容密集的应用程序。然而,我想要的功能是在软键盘弹出时继续在屏幕上半部分显示我聚焦的 EditText...
到目前为止,我的研究表明我必须使用...
<activity android:windowSoftInputMode="adjustUnspecified" android:name=".main">
<intent-filter>
<action android:name="com.last.project.main" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
有人告诉我(这个) android:windowSoftInputMode=" Manifest.xml 的“调整Unspecified”行将解决我的问题,但它似乎不起作用。 (有人告诉我意味着......从这个链接我读到 http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft )
只需要知道为什么它不起作用...是否有任何其他原因可能会影响我的清单XML 就忽略我写的内容?
如果需要任何其他代码,请告诉我
谢谢 heaps,
Krio
我的布局 XML 是...
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout android:layout_height="wrap_content"
android:id="@+id/linearLayout1"
android:layout_width="match_parent">
<ImageView android:src="@drawable/header"
android:layout_height="wrap_content"
android:id="@+id/imageView1"
android:layout_width="match_parent" >
</ImageView>
</LinearLayout>
<LinearLayout android:layout_height="wrap_content"
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:baselineAligned="false"
android:layout_gravity="fill">
<Button android:layout_height="wrap_content"
android:text="English" android:id="@+id/button1"
android:onClick="languageSelectionButtonFrom"
android:layout_width="wrap_content"
android:layout_weight="2">
</Button>
<ImageButton android:layout_height="wrap_content"
android:src="@drawable/arrow"
android:id="@+id/imageButton1"
android:layout_width="wrap_content">
</ImageButton>
<Button android:text="English"
android:onClick="languageSelectionButtonTo"
android:id="@+id/button3"
android:layout_gravity="right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2">
</Button>
</LinearLayout>
<TableLayout android:id="@+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText android:hint="Text to translate..."
android:layout_width="wrap_content"
android:id="@+id/editText1"
android:layout_height="wrap_content">
</EditText>
<Button android:text="Translate"
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="translationButtonClickHandler" >
</Button>
<TextView android:text="Translation :"
android:textSize="15sp"
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<EditText android:text=""
android:layout_width="wrap_content"
android:id="@+id/editText2"
android:scrollbars="vertical"
android:layout_weight="4"
android:gravity="top"
android:layout_height="match_parent">
</EditText>
</TableLayout>
</LinearLayout>
I am trying to make an application where content inside a Layout is dense. However I want functionality which will keep showing my focused EditText on top half of the screen while soft keyboard pops up...
So far my research says I have to use...
<activity android:windowSoftInputMode="adjustUnspecified" android:name=".main">
<intent-filter>
<action android:name="com.last.project.main" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
I have been told that (this) android:windowSoftInputMode="adjustUnspecified" line of Manifest.xml will solve my problem, However it doesn't seems to be working.
(I have been told means .... from this link I read http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft )
Just need to know why it is not working...Are there any other reasons which may affect my manifest XML to just ignore what I have wrote?
Do let me know if any other codes needed
Thanks heaps,
Krio
My layout XML is...
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout android:layout_height="wrap_content"
android:id="@+id/linearLayout1"
android:layout_width="match_parent">
<ImageView android:src="@drawable/header"
android:layout_height="wrap_content"
android:id="@+id/imageView1"
android:layout_width="match_parent" >
</ImageView>
</LinearLayout>
<LinearLayout android:layout_height="wrap_content"
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:baselineAligned="false"
android:layout_gravity="fill">
<Button android:layout_height="wrap_content"
android:text="English" android:id="@+id/button1"
android:onClick="languageSelectionButtonFrom"
android:layout_width="wrap_content"
android:layout_weight="2">
</Button>
<ImageButton android:layout_height="wrap_content"
android:src="@drawable/arrow"
android:id="@+id/imageButton1"
android:layout_width="wrap_content">
</ImageButton>
<Button android:text="English"
android:onClick="languageSelectionButtonTo"
android:id="@+id/button3"
android:layout_gravity="right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2">
</Button>
</LinearLayout>
<TableLayout android:id="@+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText android:hint="Text to translate..."
android:layout_width="wrap_content"
android:id="@+id/editText1"
android:layout_height="wrap_content">
</EditText>
<Button android:text="Translate"
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="translationButtonClickHandler" >
</Button>
<TextView android:text="Translation :"
android:textSize="15sp"
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<EditText android:text=""
android:layout_width="wrap_content"
android:id="@+id/editText2"
android:scrollbars="vertical"
android:layout_weight="4"
android:gravity="top"
android:layout_height="match_parent">
</EditText>
</TableLayout>
</LinearLayout>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题已经解决了,感谢那些尝试集思广益的人...
答案是...我们必须将所有布局内容放在滚动视图中才能使这个东西工作!
所以,就我而言
Problem has been solved Thank you for people who have attempted to brain strom...
answer is...We must put all layout content inside a scroll view to get this thing work!
So, In my case