activity设置全屏的问题 activity设置全屏时,界面底部带有EditText,当点EditText输入信息弹出键盘后会把布局往上顶,这个问题如何解决,下面是截图弹出键盘前弹出键盘后 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://topic.csdn.net/u/20100716/17/7d51bf09-f2f0-4e61-aeca-cf5db642dd44.html 按他说的,设置了android:windowSoftInputMode="adjustPan"还是没用,而且我的问题是布局的标题栏都被挤出了界面 完全看不见了 不知道为什么看看弹出键盘的截图吧 你可以将这个布局放在ScrollView里 被遮住可以用滚动条滚到下面让你显示 不行,试过了,而且这种情况只是在设置了全屏的时候出现getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 在androidMainfest.xml文件中在此Activity中写入 android:windowSoftInputMode="adjustPan" LZ结贴吧、 在androidMainfest.xml文件中在此Activity中写入 android:windowSoftInputMode="adjustResize"这样布局会自动压缩,标题栏也不会像楼主的那样被顶上去消失了。楼主,200分我到手了吗?谢谢哈 事实证明加了android:windowSoftInputMode="adjustResize"这个还是不行,至于这个帖子的确是100分,但我这个帖子发了俩次都是100分的,只要解决了这个问题,这两个帖子分就全给你了 我发下我的截图吧:1.没加adjustResize的情况:2.加了adjustResize的情况:标题栏正常显示啊,至于界面也没有被挤到屏幕上方看不见的区域 我把代码贴出来了main.xml<?xml version="1.0" encoding="utf-8"?><ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:fillViewport="true" android:scrollbarStyle="outsideInset" > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" android:layout_weight="1.0"/> <Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> <RelativeLayout android:gravity="center_vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="bottom"> <EditText android:id="@+id/editText1" android:text="EditText" android:layout_width="match_parent" android:layout_height="wrap_content"></EditText> </RelativeLayout> </LinearLayout></ScrollView>TitleTest.javapublic class TitleTest extends Activity { TextView tx; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.main); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.tab_custom_title); tx = (TextView) findViewById(R.id.textView1); tx.setText("set成功"); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);//这个属性不管是在manifest中设置还是在代码里设置都一样 findViewById(R.id.button1).setOnClickListener(new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub Intent in = new Intent(TitleTest.this, Test.class); startActivity(in); } }); }}Test.javapublic class Test extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.main); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); findViewById(R.id.button1).setOnClickListener(new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub Intent in = new Intent(Test.this, TitleTest.class); startActivity(in); } }); } } 刚才意外看到这个帖子。。楼主解决没?我遇到类似的问题,貌似在全屏下,该行为确实不能是我们所期望的那样。 参看别人的讨论: http://groups.google.com/group/android-developers/browse_thread/thread/4f5f779d58170d20http://comments.gmane.org/gmane.comp.handhelds.android.devel/52533楼主如果解决了这个问题,希望能共享信息. ^_^ 看来的程序里取得可视界面自己调解了提示ViewTreeObserver vo = getWindow().getDecorView().getViewTreeObserver();ViewTreeObserver vo = decor.getViewTreeObserver(new OnGlobalLayoutListener{...});View v = getWindow().getDecorView();v.getWindowVisibleDisplayFrame(new Rect())v.height()float density = getResources().getDisplayMetrics().density;int statusBarHeight = (int) ((STATUS_BAR_HEIGHT * density) + 0.5);int windowHeight = getWindowManager().getDefaultDisplay().getHeight();mDefaultHeight = windowHeight - statusBarHeight; <?xml version="1.0" encoding="utf-8"?> <RelativeLayout android:id="@+id/layout_conversation_main" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" > <ListView android:id="@+id/layout_conversation_list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_below="@+id/layout_conversation_title" android:layout_above="@+id/layout_conversation_editarea" android:layout_alignParentLeft="true" > </ListView> <LinearLayout android:id="@+id/layout_conversation_editarea" android:background="@drawable/titlebg" android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="0dp" android:layout_margin="0dp" android:layout_alignParentBottom="true" > <ImageButton android:id="@+id/layout_conversation_smile" android:layout_width="wrap_content" android:layout_height="fill_parent" android:src="@drawable/sel_face" android:layout_gravity="center_vertical" android:background="@drawable/sbutton_bg" > </ImageButton> <EditText android:id="@+id/layout_conversation_edit" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:textAppearance="?android:textAppearanceMedium" android:background="@drawable/s_edittext_bg" style="?android:attr/textViewStyle" android:layout_gravity="center_vertical" android:maxLines="1" > </EditText> <Button android:id="@+id/layout_conversation_send" android:layout_width="wrap_content" android:layout_height="fill_parent" android:src="@drawable/send" android:text="@string/send" android:typeface="serif" android:textStyle="bold" android:layout_margin="2dip" android:background="@drawable/button_bg" android:layout_gravity="center_vertical" > </Button> </LinearLayout> <LinearLayout android:layout_alignParentTop="true" android:background="@drawable/titlebg" android:padding="0dip" android:layout_width="fill_parent" android:id="@+id/layout_conversation_title" android:layout_alignParentRight="true" android:layout_height="wrap_content"> <ImageView android:id="@+id/layout_conversation_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/online" android:layout_gravity="center_vertical" ></ImageView> <TextView android:id="@+id/layout_conversation_displayname" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textAppearance="?android:textAppearanceSmall" android:layout_weight="1" android:layout_gravity="center_vertical" ></TextView> <ImageButton android:id="@+id/layout_conversation_camera" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/camera" android:background="@drawable/sbutton_bg" ></ImageButton> <ImageButton android:id="@+id/layout_conversation_record" android:layout_width="wrap_content" android:src="@drawable/record" android:layout_height="wrap_content" android:background="@drawable/sbutton_bg" ></ImageButton> <com.*.app.view.AlertImageView android:id="@+id/layout_conversation_alertimageview" android:background="@drawable/sbutton_bg" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout></RelativeLayout> protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(new RenderView(this)); }N);LZ试试这个 有两个办法可以解决:1:android:windowSoftInputMode="adjustResize"2:代码如下,使用RelativeLayout布局,内容部份使用ScrollView <?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:orientation="horizontal"> <ScrollView android:id="@+id/listView1" android:layout_above="@+id/linBottom" android:layout_height="fill_parent" android:background="#ffffffff" android:layout_width="fill_parent"> <LinearLayout android:layout_width="fill_parent" android:orientation="vertical" android:layout_height="wrap_content" android:id="@+id/linList"> </LinearLayout> </ScrollView> <RelativeLayout android:layout_width="fill_parent" android:layout_alignParentBottom="true" android:id="@+id/linBottom" android:layout_height="wrap_content" android:orientation="horizontal"> <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/edtSms" android:layout_toLeftOf="@+id/btnSend" /> <Button android:layout_alignParentRight="true" android:text=" 发 送 " android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/btnSend" /> </RelativeLayout></RelativeLayout> android:windowSoftInputMode="adjustResize|stateAlwaysHidden" 其他人的方法都看了下都不行,25L说的方法不是很明白,OtherEyeOpen能说详细点么, 你的程序我试了,没有问题,不会出现你说滴覆盖情况。请仔细检查,或用模拟器试试,或者更换输入法。以下是我的代码,测试正常。<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.alex.softbank.test" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="8" /> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".SoftbanktestActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".Test" android:windowSoftInputMode="adjustResize|stateAlwaysHidden" android:label="@string/app_name"> </activity> </application></manifest>package com.alex.softbank.test;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.view.Window;import android.view.WindowManager;import android.widget.TextView;public class SoftbanktestActivity extends Activity { TextView tx; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.main); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.tab_custom_title); tx = (TextView) findViewById(R.id.textView1); tx.setText("set成功"); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); findViewById(R.id.button1).setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent in = new Intent(SoftbanktestActivity.this, Test.class); startActivity(in); } }); }}package com.alex.softbank.test;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.view.WindowManager;public class Test extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.main); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); findViewById(R.id.button1).setOnClickListener(new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub Intent in = new Intent(Test.this, SoftbanktestActivity.class); startActivity(in); } }); } }main.xml<?xml version="1.0" encoding="utf-8"?><ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:fillViewport="true" android:scrollbarStyle="outsideInset" > <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" android:layout_weight="1.0"/> <Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <RelativeLayout android:gravity="center_vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="bottom"> <EditText android:id="@+id/editText1" android:text="EditText" android:layout_width="match_parent" android:layout_height="wrap_content"/> </RelativeLayout> </LinearLayout></ScrollView>tab_custom_title.xml<?xml version="1.0" encoding="utf-8"?><TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/textView1" android:layout_width="fill_parent" android:layout_height="30dip"/> 我的问题不是覆盖,是点击EditText后弹出一个键盘,此时最上边的标题栏就会被挤出界面,手机 模拟器 平板电脑都测试过都有这问题弹出键盘前的标题栏弹出键盘后的标题栏 这东西寻常方法解决不了啊,activity就那几种输入显示,一是弹上去,而是不弹,但是要是又要把底层的输入框弹上来,而activity的最顶层的布局不会被隐藏,试试在开始触发keyboard的时候缩小整体布局的高度。。如果有背景图的按比例缩放。。试试行不 我也是看别人的答复,都有说不可以的,才这么想就是自己控制可视界面自己调节尺寸,理论上可行第一段给可视范围变化注册监听上面那个OnGlobalLayoutListener就是可视界面变动会触发。这里面你手动的代码调节下自己的表示尺寸。下面分别是取得可视范围,和屏幕范围的方法。具体的自己试试吧! 可能我上面写了几个自认为计算尺寸用得着的函数更让你迷惑了其实意思就是当HARDKEYBOARDHIDDEN_NO的时候,你把你的view自己调小别让它充满能否回避掉? 楼主的uses-sdk android:minSdkVersion可能没设置,或者值小于4请设置为4及以上的值,应该能解决问题.请参考stackoverflow的帖子:http://stackoverflow.com/questions/4559367/soft-keyboard-overlapping-with-edittext-field以上 我设置的值是<uses-sdk android:minSdkVersion="5"></uses-sdk> 在Activity的onCreate函数中,加入如下代码:requestWindowFeature(Window.FEATURE_NO_TITLE);getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN , WindowManager.LayoutParams. FLAG_FULLSCREEN);注意必须放在setContentView方法前面 两年了,问题解决了吗。哈哈,我也遇到这个问题了,我的是中间有listview布局,edittext在最底层,然后没有全屏的正常表现是,弹出的输入框将edittext顶了上去,当时整体布局没有超出屏幕,listview由于空间变小,出现了scrollbar。现在全屏后,也就是没有了statusbar后,输入法弹出来后,将整个布局全顶了屏幕外面去,而且还edittext有一部分被输入法遮挡住了,就跟楼主的截图一样,不管设置神马pan resize 都不行,看来只有不全屏了 请问Intent跳到指定Activity是否可以动态跳转的? 怎样实现Android屏幕的自动左右滑动? 非空byte[] 转换成 bitmap ,bitmap 为空 android(java)中可不可以直接 open /dev/input/eventX 设备? 新手求助!!! 怎么读取android项目文件夹里的文件? 【新手求助】根据ID取多个控件的问题 程序运行出现异常,有高手帮我解决一下!!谢谢!!! setContentView();报错!!! textedit底部下划线样式问题 解析错误 解析包时出现问题 android的R.java文件无法修改怎么办?
看看弹出键盘的截图吧
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
在androidMainfest.xml文件中在此Activity中写入 android:windowSoftInputMode="adjustResize"
这样布局会自动压缩,标题栏也不会像楼主的那样被顶上去消失了。
楼主,200分我到手了吗?谢谢哈
我发下我的截图吧:
1.没加adjustResize的情况:
2.加了adjustResize的情况:标题栏正常显示啊,至于界面也没有被挤到屏幕上方看不见的区域
main.xml<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:scrollbarStyle="outsideInset" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/hello"
android:layout_weight="1.0"/>
<Button android:text="Button" android:id="@+id/button1"
android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
<RelativeLayout android:gravity="center_vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_gravity="bottom">
<EditText android:id="@+id/editText1" android:text="EditText"
android:layout_width="match_parent" android:layout_height="wrap_content"></EditText>
</RelativeLayout>
</LinearLayout>
</ScrollView>TitleTest.javapublic class TitleTest extends Activity {
TextView tx;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
R.layout.tab_custom_title);
tx = (TextView) findViewById(R.id.textView1);
tx.setText("set成功");
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);//这个属性不管是在manifest中设置还是在代码里设置都一样
findViewById(R.id.button1).setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent in = new Intent(TitleTest.this, Test.class);
startActivity(in);
}
});
}
}Test.javapublic class Test extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
findViewById(R.id.button1).setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent in = new Intent(Test.this, TitleTest.class);
startActivity(in);
}
});
}
}
http://groups.google.com/group/android-developers/browse_thread/thread/4f5f779d58170d20http://comments.gmane.org/gmane.comp.handhelds.android.devel/52533楼主如果解决了这个问题,希望能共享信息. ^_^
提示
ViewTreeObserver vo = getWindow().getDecorView().getViewTreeObserver();
ViewTreeObserver vo = decor.getViewTreeObserver(new OnGlobalLayoutListener{...});View v = getWindow().getDecorView();
v.getWindowVisibleDisplayFrame(new Rect())
v.height()float density = getResources().getDisplayMetrics().density;
int statusBarHeight = (int) ((STATUS_BAR_HEIGHT * density) + 0.5);
int windowHeight = getWindowManager().getDefaultDisplay().getHeight();
mDefaultHeight = windowHeight - statusBarHeight;
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/layout_conversation_main"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<ListView
android:id="@+id/layout_conversation_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/layout_conversation_title"
android:layout_above="@+id/layout_conversation_editarea"
android:layout_alignParentLeft="true"
>
</ListView>
<LinearLayout
android:id="@+id/layout_conversation_editarea"
android:background="@drawable/titlebg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="0dp"
android:layout_margin="0dp"
android:layout_alignParentBottom="true"
>
<ImageButton
android:id="@+id/layout_conversation_smile"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:src="@drawable/sel_face"
android:layout_gravity="center_vertical"
android:background="@drawable/sbutton_bg"
>
</ImageButton>
<EditText
android:id="@+id/layout_conversation_edit"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textAppearance="?android:textAppearanceMedium"
android:background="@drawable/s_edittext_bg"
style="?android:attr/textViewStyle"
android:layout_gravity="center_vertical"
android:maxLines="1"
>
</EditText>
<Button
android:id="@+id/layout_conversation_send"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:src="@drawable/send"
android:text="@string/send"
android:typeface="serif"
android:textStyle="bold"
android:layout_margin="2dip"
android:background="@drawable/button_bg"
android:layout_gravity="center_vertical"
>
</Button>
</LinearLayout>
<LinearLayout
android:layout_alignParentTop="true"
android:background="@drawable/titlebg"
android:padding="0dip"
android:layout_width="fill_parent"
android:id="@+id/layout_conversation_title"
android:layout_alignParentRight="true"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/layout_conversation_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/online"
android:layout_gravity="center_vertical"
></ImageView>
<TextView
android:id="@+id/layout_conversation_displayname"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:textAppearanceSmall"
android:layout_weight="1"
android:layout_gravity="center_vertical"
></TextView>
<ImageButton
android:id="@+id/layout_conversation_camera"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/camera"
android:background="@drawable/sbutton_bg"
></ImageButton>
<ImageButton
android:id="@+id/layout_conversation_record"
android:layout_width="wrap_content"
android:src="@drawable/record"
android:layout_height="wrap_content"
android:background="@drawable/sbutton_bg"
></ImageButton>
<com.*.app.view.AlertImageView
android:id="@+id/layout_conversation_alertimageview"
android:background="@drawable/sbutton_bg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
</RelativeLayout>
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(new RenderView(this)); }N);LZ试试这个
1:android:windowSoftInputMode="adjustResize"
2:代码如下,使用RelativeLayout布局,内容部份使用ScrollView
<?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:orientation="horizontal">
<ScrollView android:id="@+id/listView1" android:layout_above="@+id/linBottom"
android:layout_height="fill_parent" android:background="#ffffffff"
android:layout_width="fill_parent">
<LinearLayout android:layout_width="fill_parent"
android:orientation="vertical" android:layout_height="wrap_content"
android:id="@+id/linList">
</LinearLayout>
</ScrollView> <RelativeLayout android:layout_width="fill_parent"
android:layout_alignParentBottom="true" android:id="@+id/linBottom"
android:layout_height="wrap_content" android:orientation="horizontal">
<EditText android:layout_width="fill_parent"
android:layout_height="wrap_content" android:id="@+id/edtSms"
android:layout_toLeftOf="@+id/btnSend" />
<Button android:layout_alignParentRight="true" android:text=" 发 送 "
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:id="@+id/btnSend" />
</RelativeLayout>
</RelativeLayout>
以下是我的代码,测试正常。<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.alex.softbank.test"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" /> <application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".SoftbanktestActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity> <activity android:name=".Test"
android:windowSoftInputMode="adjustResize|stateAlwaysHidden"
android:label="@string/app_name">
</activity> </application>
</manifest>
package com.alex.softbank.test;import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;public class SoftbanktestActivity extends Activity { TextView tx;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
R.layout.tab_custom_title);
tx = (TextView) findViewById(R.id.textView1);
tx.setText("set成功");
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
findViewById(R.id.button1).setOnClickListener(new OnClickListener() { public void onClick(View v) {
Intent in = new Intent(SoftbanktestActivity.this, Test.class);
startActivity(in);
}
});
}
}package com.alex.softbank.test;import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;public class Test extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
findViewById(R.id.button1).setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent in = new Intent(Test.this, SoftbanktestActivity.class);
startActivity(in);
}
});
}
}
main.xml<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:scrollbarStyle="outsideInset" >
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"> <TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
android:layout_weight="1.0"/> <Button android:text="Button"
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/> <RelativeLayout android:gravity="center_vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"> <EditText android:id="@+id/editText1"
android:text="EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>
</LinearLayout>
</ScrollView>
tab_custom_title.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="30dip"/>
弹出键盘前的标题栏弹出键盘后的标题栏
试试在开始触发keyboard的时候缩小整体布局的高度。。如果有背景图的按比例缩放。。试试行不
就是自己控制可视界面自己调节尺寸,理论上可行
第一段给可视范围变化注册监听
上面那个OnGlobalLayoutListener就是可视界面变动会触发。
这里面你手动的代码调节下自己的表示尺寸。
下面分别是取得可视范围,和屏幕范围的方法。
具体的自己试试吧!
其实意思就是当HARDKEYBOARDHIDDEN_NO的时候,你把你的view自己调小
别让它充满能否回避掉?
请设置为4及以上的值,应该能解决问题.
请参考stackoverflow的帖子:
http://stackoverflow.com/questions/4559367/soft-keyboard-overlapping-with-edittext-field以上
<uses-sdk android:minSdkVersion="5"></uses-sdk>
getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN ,
WindowManager.LayoutParams. FLAG_FULLSCREEN);
注意必须放在setContentView方法前面