2017-03-10 47 views
0

我在我的活動中有NestedScrollView,約有7-8個編輯文本,我需要它們在顯示鍵盤時向上移動。我這樣做,但它不工作當顯示鍵盤時佈局不動了

android:windowSoftInputMode="adjustPan|adjustResize" 

activity.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/activity_login" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/colorPrimary" 
    android:focusableInTouchMode="true" 
    tools:context="com.amir_p.cafino.LoginActivity"> 

    <ImageView 
     android:id="@+id/back_img" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:scaleType="centerCrop" /> 

    <View 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@color/grayTransparent" /> 

    <android.support.v4.widget.NestedScrollView 
     android:layout_width="match_parent" 
     android:id="@+id/signup_layout" 
     android:fillViewport="true" 
     android:layout_height="wrap_content" 
     android:visibility="gone"> 

     <LinearLayout 
      android:id="@+id/register_layout" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:gravity="center_horizontal" 
      android:orientation="vertical" 
      android:padding="16dp"> 

      <android.support.design.widget.TextInputLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="36dp" 
       android:hint="نام و نام خانوادگی" 
       android:textColorHint="@color/white"> 

       <android.support.design.widget.TextInputEditText 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:backgroundTint="@color/white" /> 
      </android.support.design.widget.TextInputLayout> 

      [...] 
     </LinearLayout> 
    </android.support.v4.widget.NestedScrollView> 
</RelativeLayout> 

回答

0

爭取你的滾動視圖

<android.support.v4.widget.NestedScrollView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:fillViewport="true" 
    android:visibility="visible"> 

並在清單中添加增加android:fillViewport="true"

android:windowSoftInputMode="stateVisible|adjustResize" 

你可以編程關掉屏幕模式:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); 
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); 

全屏模式不會調整大小。

或U可以使用不同的主題:android:theme="@android:style/Theme.Black.NoTitleBar

+0

它不工作。我已經更新了我的帖子 –

+0

嘗試設置'android:fillViewport =「false」'... – rafsanahmad007

+0

另外,如果你使用全屏主題進行你的活動...你需要改變它 – rafsanahmad007