2014-12-19 4 views
1

Я использую этот код. Однако когда я нажимаю на EditText, чтобы открыть клавиатуру, представление не полностью вверх. Почему мнение не собирается всю дорогу, EditText скрывается за клавиатуройКлавиатура не прокручивается EditText выше

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:gravity="center_horizontal" 
    android:background="@drawable/main_bg" 
    android:id="@+id/mainLayout" 
    android:focusableInTouchMode="true" 
    > 

     <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="40dp" 
     android:orientation="horizontal" 
     android:id="@+id/topBar" 
     android:background="@drawable/top_bar_bg" 
    > 

     <LinearLayout 
       android:layout_height="wrap_content" 
       android:layout_width="wrap_content" 
       android:orientation="horizontal" 
       android:gravity="center_horizontal|bottom" 
       android:layout_centerInParent="true" 
      > 

       <ImageView 
        android:id="@+id/loadingAnimationImg" 
        android:layout_height="35dp" 
        android:layout_width="35dp" 
        android:adjustViewBounds="true" 
        android:contentDescription="@null" 
        android:background="@drawable/img05"/> 

       <ImageView 
        android:layout_marginBottom="5dp" 
        android:layout_height="wrap_content" 
        android:layout_width="120dp" 
        android:adjustViewBounds="true" 
        android:contentDescription="@null" 
        android:src="@drawable/simple_logo"/> 

     </LinearLayout> 
    </RelativeLayout> 

    <GridView 
      android:layout_marginTop="5dp" 
      android:layout_width="match_parent" 
      android:layout_height="300dp" 
      android:id="@+id/gridView" 
      android:numColumns="5" 
      android:verticalSpacing="5dp" /> 

    <TextView 
     android:layout_marginTop="5dp" 
     android:layout_marginLeft="10dp" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:textSize="12sp" 
     android:textColor="@android:color/white" 
     android:text="@string/hashtagText" 
     /> 


    <com.trib.devicebee.custom.FlowLayout 
     android:id="@+id/flowLayout" 
     android:layout_margin="10dp" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     /> 

    <EditText 
     android:layout_margin="10dp" 
     android:id="@+id/hashTagsText" 
     android:hint="" 
     android:inputType="textFilter" 
     android:singleLine="true" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:textSize="12sp" 
     /> 

    <Button 
     android:id="@+id/goAheadBtn" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="@drawable/go_ahead_btn" 
     android:layout_margin="10dp" 
     /> 

</LinearLayout> 

ответ

1

пытаться играть с андроида: windowSoftInputMode атрибут AndroidManifest.xml - «adjustPan» может быть ответом.

<activity 
    android:name="MyActivity" 
    android:windowSoftInputMode="adjustPan" 
    android:configChanges="orientation|keyboardHidden|screenSize" 
    > 
</activity> 
-1

Лучшее решение, которое я придумал, чтобы поставить все в Scrollview.

  • Сейчас в очевидном

    <activity 
        android:name="MyActivity" 
        android:windowSoftInputMode="adjustResize"> 
    </activity> 
    
  • Теперь используйте onfocusChangeListener на EditText вы хотите сосредоточиться

    editText.setOnFocusChangeListener(new View.OnFocusChangeListener() { 
        @Override 
        public void onFocusChange(View view, boolean b) { 
         if (b){ 
         scrollView.smoothScrollTo(0,editText.getBottom()+5); 
         } 
        } 
    }); 
    

И мы сделали.

+0

Не спрашивайте [копировать и вставлять ответы] (http://stackoverflow.com/questions/3295672/android-soft-keyboard-covers-edittext-field/39357566#39357566) между вопросами. Если один и тот же ответ применяется к обоим вопросам, один вопрос должен быть помечен как дубликат, а не ответа. – miken32