2015-09-23 118 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