[英]android softkeyboard pushes layout up
所以基本上我有一個主要的布局,它是登錄屏幕。 問題是當我點擊Edittext字段時,整個相對布局都會消失在屏幕上...
這是我的xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background_gradient"
android:theme="@android:style/Theme.NoTitleBar"
tools:context=".MainActivity" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/editText1"
android:layout_centerHorizontal="true"
android:layout_marginBottom="60dp"
android:baselineAlignBottom="true"
android:contentDescription="@string/skedo"
android:src="@drawable/logo" />
<EditText
android:id="@+id/editText1"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_above="@+id/editText2"
android:layout_centerHorizontal="true"
android:layout_marginLeft="13dp"
android:layout_marginRight="13dp"
android:drawableLeft="@drawable/user"
android:drawablePadding="13dp"
android:paddingLeft="13dp"
android:inputType="textEmailAddress"
android:background="@drawable/round_corners"
android:ems="10"
android:hint="@string/email" />
<EditText
android:id="@+id/editText2"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_centerInParent="true"
android:layout_marginLeft="13dp"
android:layout_marginRight="13dp"
android:layout_marginTop="8dp"
android:drawableLeft="@drawable/lock"
android:drawablePadding="13dp"
android:paddingLeft="13dp"
android:background="@drawable/round_corners"
android:ems="10"
android:hint="@string/password"
android:inputType="textPassword" >
</EditText>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/editText2"
android:layout_centerHorizontal="true"
android:layout_marginTop="8dp"
android:textSize="17sp"
android:shadowColor="#000000"
android:shadowRadius="1"
android:shadowDx="0"
android:shadowDy="1"
android:text="@string/login"
android:textColor="#ffffff"
android:background="@drawable/button_states" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/button1"
android:layout_centerInParent="true"
android:layout_marginTop="23dp"
android:clickable="true"
android:text="@string/forgot_password"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="13sp" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="23dp"
android:contentDescription="@string/imgdesc"
android:src="@drawable/or" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/imageView2"
android:shadowColor="#ffffff"
android:shadowRadius="1"
android:shadowDx="0"
android:textSize="14sp"
android:textStyle="bold"
android:shadowDy="1"
android:layout_centerHorizontal="true"
android:layout_marginTop="23dp"
android:text="@string/register"
android:background="@drawable/create_account"
/>
因此,當發生這種情況時,我的徽標將從屏幕上消失,我希望它能夠顯示出來。 最好的例子是Facebook登錄屏幕,當您點擊editText時,它將擠壓所有內容,徽標仍然可見。 那我怎樣才能達到這樣的效果呢?
因此,當什么都沒按下時: http : //postimage.org/image/swdtggnil/
當鍵盤出現http://postimage.org/image/5pbdfrftl/
我希望它表現得完全一樣。
如果我沒有誤會,您可以添加
android:windowSoftInputMode="adjustPan"
在AndroidManifest.xml
<activity
android:name="yourActivity"
android:windowSoftInputMode="adjustPan" >
</activity>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.