在我的Android应用程序中我有一个登录页面,我需要在键盘打开时推动整个视图现在发生的事情是..我有两个edittext一个用户名,另一个用于密码和两个textview下面的忘记密码和新用户所以当我点击用户名edittext键盘打开并隐藏密码edittext和textviews时,我需要的是键盘需要推高整个视图..所以用户不需要按后退按钮来隐藏键盘去密码编辑文本..
我尝试了什么...... 我给了
android:windowSoftInputMode="stateVisible|adjustResize|adjustPan"
在android清单中的活动和
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
在oncreate中,但它仍隐藏着edittext和textviews ......我知道如何克服这种情况请帮忙
我的xml在下面给出了
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/logo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:background="@color/red">
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/contentDescriptionContent"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:src="@mipmap/logo" />
</LinearLayout>
<LinearLayout
android:id="@+id/loginNow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/logo"
android:gravity="center"
android:background="@drawable/main_header_selector">
<TextView
android:id="@+id/textViewAboutUs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:text="LOGIN NOW"
android:textColor="@color/red"
android:shadowColor="#FFFFFF"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="2"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
<ScrollView
android:id="@+id/sView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/loginNow">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp">
<EditText
android:id="@+id/editTextUserName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Mobile Number"
android:inputType="number"
android:maxLines="1"
android:padding="10dp"
android:background="@drawable/rect_text_edittext"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_marginTop="75dp"/>
<EditText
android:id="@+id/editTextPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/password"
android:inputType="textPassword"
android:maxLines="1"
android:padding="10dp"
android:background="@drawable/rect_text_edittext"
android:layout_below="@+id/editTextUserName"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_marginTop="3dp"/>
<Button
android:id="@+id/login_Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_below="@+id/editTextPassword"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:shadowColor="#000000"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="2"
android:gravity="center"
android:minHeight="30dp"
android:textColor="#ffffff"
android:background="@drawable/custom_button"
android:text="@string/login" />
<TextView
android:id="@+id/textViewIfNewUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/login_Button"
android:layout_marginTop="8dp"
android:layout_marginLeft="55dp"
android:layout_alignParentLeft="true"
android:text="@string/ifnewuser"
android:textColor="#000000"
android:textStyle="italic|bold"/>
<TextView
android:id="@+id/textViewNewUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/textViewIfNewUser"
android:layout_alignBaseline="@+id/textViewIfNewUser"
android:layout_marginLeft="8dp"
android:text="@string/newuser"
android:textColor="@drawable/text_color_red"
android:textStyle="italic|bold"/>
<TextView
android:id="@+id/textViewIfForgotPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textViewIfNewUser"
android:layout_marginTop="8dp"
android:layout_marginLeft="55dp"
android:layout_alignParentLeft="true"
android:text="@string/ifforgotpassword"
android:textColor="#000000"
android:textStyle="italic|bold"/>
<TextView
android:id="@+id/textViewForgotPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/textViewIfForgotPassword"
android:layout_alignBaseline="@+id/textViewIfForgotPassword"
android:layout_marginLeft="8dp"
android:text="@string/forgotpassword"
android:textColor="@drawable/text_color_red"
android:textStyle="italic|bold"/>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
答案 0 :(得分:1)
在AndroidManifest中尝试将活动代码中的softInputMode值调整为&#34; adjustResize&#34;
e.g。
<activity
android:name="YourActivity"
android:windowSoftInputMode="adjustResize">
</activity>
我认为这个问题可能是因为您提供了其他选项,因为&#34; adjustPan&#34;选项允许键盘在布局上停留
答案 1 :(得分:0)
你试过这个:
android:windowSoftInputMode="adjustResize"