Android 键盘只能平移一次布局
有一个问题我找不到解决办法。当我启动活动时,当我第一次选择Android 键盘只能平移一次布局,android,android-softkeyboard,Android,Android Softkeyboard,有一个问题我找不到解决办法。当我启动活动时,当我第一次选择EditText字段时,键盘工作正常(它平移布局)。当我最小化键盘并再次选择它时,它与布局和所需的EditText重叠 我已经在我的androidManifest.xml中添加了android:windowSoftInputMode=“adjustPan”,尽管它不起作用 有人知道如何解决这个问题吗?请使用AndroidManifest.xml中的android:windowSoftInputMode=“stateVisible | ad
EditText
字段时,键盘工作正常(它平移布局)。当我最小化键盘并再次选择它时,它与布局和所需的EditText
重叠
我已经在我的androidManifest.xml
中添加了android:windowSoftInputMode=“adjustPan”
,尽管它不起作用
有人知道如何解决这个问题吗?请使用
AndroidManifest.xml中的android:windowSoftInputMode=“stateVisible | adjustResize”
请使用android:windowSoftInputMode=“stateVisible | adjustResize”
在AndroidManifest.xml中
请检查这个简单完整的代码,它可以正常工作,我已经为您测试过了。
Please check this simple and complete code and it works, i have tested it for you.
manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test22"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
MainActivity:
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
xml layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.test22.MainActivity" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="62dp"
android:layout_toRightOf="@+id/textView1"
android:ems="10" >
<requestFocus />
</EditText>
</RelativeLayout>
Just copy it, it rocks
显示:
主要活动:
公共类MainActivity扩展了活动{
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@凌驾
公共布尔onCreateOptions菜单(菜单){
//为菜单充气;这会将项目添加到操作栏(如果存在)。
getMenuInflater().充气(R.menu.main,menu);
返回true;
}
@凌驾
公共布尔值onOptionsItemSelected(菜单项项){
//处理操作栏项目单击此处。操作栏将
//自动处理Home/Up按钮上的点击,只要
//在AndroidManifest.xml中指定父活动时。
int id=item.getItemId();
if(id==R.id.action\u设置){
返回true;
}
返回super.onOptionsItemSelected(项目);
}
}
xml布局:
复制它,它会摇滚
请检查这个简单完整的代码,它可以正常工作,我已经为您测试过了。
显示:
主要活动:
公共类MainActivity扩展了活动{
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@凌驾
公共布尔onCreateOptions菜单(菜单){
//为菜单充气;这会将项目添加到操作栏(如果存在)。
getMenuInflater().充气(R.menu.main,menu);
返回true;
}
@凌驾
公共布尔值onOptionsItemSelected(菜单项项){
//处理操作栏项目单击此处。操作栏将
//自动处理Home/Up按钮上的点击,只要
//在AndroidManifest.xml中指定父活动时。
int id=item.getItemId();
if(id==R.id.action\u设置){
返回true;
}
返回super.onOptionsItemSelected(项目);
}
}
xml布局:
复制它,它会摇滚
我注意到的一件事是,很多人在添加
android:windowSoftInputMode="stateVisible|adjustResize"
在他们的布局文件中,实际上它需要在您的AndroidManifest.xml活动定义中
<activity
android:name=".user_interface.SettingsActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateVisible|adjustResize" />
我注意到的一件事是,很多人在添加
android:windowSoftInputMode="stateVisible|adjustResize"
在他们的布局文件中,实际上它需要在您的AndroidManifest.xml活动定义中
<activity
android:name=".user_interface.SettingsActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateVisible|adjustResize" />
当我回答maveroid时,使用这个android:windowSoftInputMode=“adjustResize | stateHidden”@kirankumar,adjustResize选项仍然使我的编辑文本在键盘下重叠。您应该为布局提供一个滚动视图,以便在键盘打开时可以向上滚动这是您需要的。这更像是一种解决方法,而不是解决方案;)仅供将来参考:我遇到了一个与您类似的问题,原因是EditText中的“重心”。已将其删除并正在工作。我猜这只是来自操作系统的一个bug(还有一个)。当我回答maveroid时,使用这个android:WindowsOfInputMode=“adjustResize | stateHidden”@kirankumar,adjustResize选项仍然使我的编辑文本在键盘下重叠。您应该为布局提供一个滚动视图,以便在键盘打开时可以向上滚动这是您需要的。这更像是一种解决方法,而不是解决方案;)仅供将来参考:我遇到了一个与您类似的问题,原因是EditText中的“重心”。已将其删除并正在工作。我猜这只是操作系统的一个错误(还有一个)。这不起作用,EditText字段仍然重叠:/虽然这可能会解决OP的问题,但几句解释将帮助当前和未来的读者更好地理解你的答案。这不起作用,EditText字段仍然重叠:/虽然这可以解决OP的问题,但几句解释将帮助当前和未来的读者更好地理解您的答案。