2015-09-23 116 views
0

在我的android应用程序我有一个登录页面,我需要推动整个视图,当键盘被打开时现在发生什么事情..我有两个edittext一个用户名和另一个密码和两个textview下面为忘记密码和新用户,所以当我点击用户名edittext键盘打开并隐藏密码edittext和textviews,我需要的是键盘需要推高整个视图..所以用户不需要按后退按钮隐藏在keybord用于将密码编辑文本..安卓推视图

我想什么...... 我给

android:windowSoftInputMode="stateVisible|adjustResize|adjustPan" 

在活动Android清单和

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 
在OnCreate中

,但仍隐藏着的EditText和textviews ... I F有人知道如何克服这种情况,请帮助

我的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

你有没有尝试过这样的:

android:windowSoftInputMode="adjustResize" 
1

在你的A ndroidManifest尝试将您的activity标签中的softInputMode值调整为仅“adjustResize”

例如,

<activity 
android:name="YourActivity" 
      android:windowSoftInputMode="adjustResize"> 
</activity> 

我认为这个问题可能是因为你有自“adjustPan”选项中提供的其他选项可以让你的键盘上休息布局

+0

没有顶..我检查....它不是工作..我需要..有一件事我们需要让我们的父视图滚动视图..我的父视图是相对布局 – Jocheved

+0

不,你不应该包含所有的滚动视图,因为该标志处理。您是否尝试过注释掉您在onCreate中放置的“getWindow ..”函数,因为您在清单中进行了更改? – JesterXiii