我正在尝试创建一个非常基本的聊天屏幕,其中ListView显示文本,底部是EditText,EditText右侧是"发送"按钮.一切都很实用,但当我点击EditText时,虚拟键盘会覆盖它.屏幕平移一点但不足以在键盘上方可见.我的清单中有"adjustPan"标签,并且还尝试了"adjustResize"标签无效.我猜这与我的布局设置方式有关,但老实说我没有任何线索.请帮忙!
当前布局......
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView android:id="@+id/android:list"
android:layout_height="0dip"
android:layout_width="fill_parent"
android:layout_weight="1"
android:stackFromBottom="true">
</ListView>
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<EditText android:id="@+id/sendMessageBox"
android:focusable="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:scrollbars="vertical"
android:maxLines="4"
android:text=""
android:inputType="textShortMessage|textAutoCorrect|textCapSentences|textMultiLine"
android:maxLength="1000"
android:hint="Type your message..."
android:imeOptions="actionSend"/>
<Button android:id="@+id/sendMessageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:text="Send"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
android android-manifest android-layout android-softkeyboard
我把一个简单的测试项目放在一起,显示一个包含EditText的PopupWindow(在Android 2.2上).当我点击EditText时,会显示软键盘,正如我所料.但是,软键盘覆盖了EditText,我无法让屏幕平移,以便按照我认为的方式保持EditText.我的代码:
TestAdjustPanActivity.java:
package com.example;
import android.app.Activity;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.view.Gravity;
import android.widget.PopupWindow;
public class TestAdjustPanActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final PopupWindow pw = new PopupWindow(this);
pw.setContentView(getLayoutInflater().inflate(R.layout.popup, null, false));
pw.setWidth(400);
pw.setHeight(600);
pw.setFocusable(true);
pw.setOutsideTouchable(true);
pw.setTouchable(true);
pw.setBackgroundDrawable(new BitmapDrawable());
// This is the line referred to in the edit:
pw.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
findViewById(R.id.main).post(new Runnable() {
public void run() {
pw.showAtLocation(findViewById(R.id.main), Gravity.NO_GRAVITY, 0, 0);
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
main.xml中:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main"
android:layout_width="fill_parent"
android:layout_height="fill_parent" …Run Code Online (Sandbox Code Playgroud) 在我的片段中,我在scrollview中有一个editText,当我点击它时,我将它设置为打开如下:
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
Run Code Online (Sandbox Code Playgroud)
它从第一次打开时工作正常,但当我关闭键盘并再次打开它时,它与editText重叠,如何将editText设置为始终在SOFT_INPUT_ADJUST_PAN模式下打开?
XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/alabaster">
<TextView
android:id="@+id/semconexao"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Verifique sua conexão com a internet"
android:gravity="center"
android:layout_marginTop="10dp"
android:visibility="gone"/>
<ScrollView
android:id="@+id/scroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/footer">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="visible">
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/imageInst"
android:layout_width="match_parent"
android:layout_height="200dp"
android:scaleType="centerCrop"
android:visibility="visible" />
<com.retornar.utils.CircledNetworkImageView
android:id="@+id/thumbnail"
android:layout_width="@dimen/logo_maior"
android:layout_height="@dimen/logo_maior"
android:layout_marginLeft="20dp"
android:layout_marginTop="100dp"
android:adjustViewBounds="true"
android:scaleType="centerCrop">
</com.retornar.utils.CircledNetworkImageView>
<ImageView
android:id="@+id/more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_amp"
android:visibility="gone"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
<TextView
android:id="@+id/retornarTitulo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/imageInst"
android:layout_marginTop="20dp"
android:gravity="center"
android:padding="10dp"
android:text="@string/retornarTitulo"
android:textColor="@color/armadillo"
android:textSize="@dimen/text2" /> …Run Code Online (Sandbox Code Playgroud) 嗨,我有活动,其中包含3个视图
-RelativeLayout
---TextView 1)
---ScrollView 2)
-----FrameLayout
---------ListView
---------EditText -----------> When I click over here (2) view only pushup
---TextView 3)
Run Code Online (Sandbox Code Playgroud)
我只想要2),这是滚动视图应该伏地挺身时键盘开放,但现在它推的TextView 3)也
我已经尝试过使用清单
android:windowSoftInputMode="adjustNothing"
or
android:windowSoftInputMode="adjustResize"
or
android:windowSoftInputMode="adjustPan"
Run Code Online (Sandbox Code Playgroud)
但没有任何反应,3)textview也推动了2)Scrollview
我有一个EditText,它最终位于ScrollView中.我已经实现了一个注释功能,可以将您带到一个新活动,并自动将焦点放在编辑文本中,以便用户可以立即开始编写他的注释.
遗憾的是,它并没有将edittext滚动到视图中,如下面的屏幕截图所示:

我希望看到更像这样的东西,其中EditText完全进入视图(见下文).我已经看过了android:WindowSoftInputMode,似乎默认值应该可以工作......事实上,它确实起作用,因为它确实滚动,但还不够.

那么我能做些什么才能获得理想的行为?谢谢!
我有,我有一个登录界面中,当我们点击编辑文本的SoftInput键盘覆盖两个小部件一个是TextView的,另一种是登录按钮,这是相对布局有问题,但我想,当我们选择任何编辑文本全相对布局应该是Up,并且所有小部件都在Android默认的软输入键盘上方可见.请建议我找到合适的解决方案.
提前致谢.
我的布局:
<?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:background="#ffffff">
<FrameLayout android:id="@+id/frame"
android:layout_gravity="top|bottom|center_horizontal"
android:layout_width="wrap_content" android:layout_marginTop="10dip" android:layout_height="wrap_content">
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="@drawable/logo" >
</ImageView>
</FrameLayout>
<RelativeLayout android:id="@+id/frameLayout1"
android:layout_width="wrap_content" android:background="@drawable/login_box_bg"
android:layout_gravity="center_horizontal" android:layout_height="220dip" android:layout_marginTop="20dip">
<EditText android:id="@+id/ed_Login_Email"
android:background="@drawable/login_input_bg" android:layout_gravity="center_horizontal" android:layout_marginTop="10dip" android:hint="Email:" android:paddingLeft="10dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:inputType="text" android:layout_centerHorizontal="true">
</EditText>
<EditText android:background="@drawable/login_input_bg" android:layout_gravity="center_horizontal" android:id="@+id/ed_Login_Pwd"
android:inputType="textPassword" android:hint="Password:" android:paddingLeft="10dip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="50dip" android:layout_centerHorizontal="true">
</EditText>
<ImageView
android:id="@+id/img_Login_RememberUnchecked"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:background="@drawable/checkbox_unchkd_large" android:layout_gravity="top|left" android:layout_marginLeft="15dip" android:layout_marginTop="100dip" android:clickable="true"/>
<TextView
android:id="@+id/tv_Login_RememberMeUnchecked"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Remember Me" android:textColor="#000000" android:layout_gravity="top|left" android:layout_marginLeft="35dip" android:layout_marginTop="102dip" android:clickable="true"/>
<Button
android:id="@+id/btn_Login_Login" …Run Code Online (Sandbox Code Playgroud)