4

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

Я использую RelativeLayout как моя основную раскладку и мой колонтитула RelativeLayout тоже, я нашел в интернете этих конфигураций:

андроид: windowSoftInputMode = «adjustPan | adjustResize»

Он работает в сноске остается фиксированным, но мой свиток не работает, это моя главная проблема, что я могу сделать для его решения?

Моя раскладка:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@drawable/background" 
    android:focusable="true" 
    android:fitsSystemWindows="true" 
    android:orientation="vertical" > 

    <ScrollView 
     android:id="@+id/scrollView1" 
     android:fillViewport="true" 
     android:isScrollContainer="true" 
     android:fitsSystemWindows="true" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" > 

      <LinearLayout 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal" > 

       <TextView 
        android:id="@+id/ttvp1" 
        style="@style/ttvPersonalizado" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="@string/p1" /> 

       <TextView 
        android:id="@+id/ttvp2" 
        style="@style/ttvPersonalizadoDireito" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="@string/p2" /> 
      </LinearLayout> 

      <LinearLayout 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal" > 


       <EditText 
        android:id="@+id/edtP1" 
        style="@style/edtPersonalizado" 
        android:maxLength="5" 
        android:layout_height="wrap_content" 
        android:background="@drawable/edit_text_design" 
        android:ems="10" 
        android:inputType="numberDecimal" > 
       </EditText> 

       <EditText 
        android:id="@+id/edtP2" 
        style="@style/edtPersonalizado" 
        android:maxLength="5" 
        android:layout_height="wrap_content" 
        android:background="@drawable/edit_text_design" 
        android:ems="10" 
        android:inputType="numberDecimal" /> 

      </LinearLayout> 

      <TextView 
       android:id="@+id/ttvpim" 
       style="@style/ttvPersonalizado" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:text="@string/pip3" /> 

      <EditText 
       android:id="@+id/edtPiP3" 
       style="@style/edtPersonalizado" 
       android:maxLength="5" 
       android:layout_height="wrap_content" 
       android:background="@drawable/edit_text_design" 
       android:inputType="numberDecimal" /> 

      <LinearLayout 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" > 

       <TextView 
        android:id="@+id/ttvExame" 
        style="@style/ttvPersonalizado" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:paddingRight="18dp" 
        android:text="@string/notaExame" /> 

       <CheckBox 
        android:id="@+id/chkExame" 
        style="@style/chkPersonalizado" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="40dp" 
        android:text="@string/exame" /> 
      </LinearLayout> 

      <LinearLayout 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" > 

       <EditText 
        android:id="@+id/edtExame" 
        style="@style/edtPersonalizado" 
        android:maxLength="5" 
        android:layout_height="wrap_content" 
        android:background="@drawable/edit_text_design" 
        android:ems="10" 
        android:enabled="false" 
        android:inputType="numberDecimal" 
        android:width="125dp" /> 

       <CheckBox 
        android:id="@+id/chkPersonalizado" 
        style="@style/chkPersonalizado" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="@string/tecnologo" /> 
      </LinearLayout> 

      <TextView 
       style="@style/ttvPersonalizado" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:text="@string/mediaFinal" /> 

      <EditText 
       android:id="@+id/edtMedia" 
       style="@style/edtPersonalizado" 
       android:maxLength="5" 
       android:layout_height="wrap_content" 
       android:background="@drawable/edit_text_design" 
       android:enabled="false" 
       android:inputType="numberDecimal" /> 

      <TextView 
       android:id="@+id/ttvStatus" 
       style="@style/ttvPersonalizado" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="" /> 

      <LinearLayout 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" > 

       <ImageButton 
        android:id="@+id/btnGerarMedia" 
        style="@style/btnMedio" 
        android:background="@drawable/shapebutton" 
        android:contentDescription="@string/gerarMedia" 
        android:src="@drawable/icone_calculadora" 
        android:text="@string/gerarMedia" /> 
      </LinearLayout> 
     </LinearLayout> 
    </ScrollView> 

    <RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="50dip" 
    android:layout_alignParentBottom="true" 
    android:background="@drawable/background_footer" 
    android:orientation="vertical" > 

    <com.google.ads.AdView 
     android:id="@+id/adView" 
     android:layout_width="fill_parent" /> 


</RelativeLayout> 

</RelativeLayout> 

Моя конфигурация деятельность в AndroidManifest:

<activity 
      android:name="br.com.media_universidades.visao.MediaCalculoActivity" 
      android:icon="@drawable/ic_launcher" 
      android:label="@string/umc" android:windowSoftInputMode="adjustPan|adjustResize"/> 

Спасибо заранее.

+2

Добавьте свой макет к вопросу, чтобы мы могли видеть, с чем вы работаете. –

+0

Отредактируйте свой макет и подтвердите, что он имеет scrollview –

+1

Измените 'android: windowSoftInputMode' значение на' android: windowSoftInputMode = "stateVisible | adjustResize'. Надеюсь, он поможет – piotrek1543

ответ

1

В зависимости от версии на Android вы используете, и как ваш макет будет иметь другое решение:

<activity 
    android:name="br.com.media_universidades.visao.MediaCalculoActivity" 
       android:icon="@drawable/ic_launcher" 
       android:label="@string/umc" 
    android:windowSoftInputMode="adjustResize"> 

редактирование: фиксированный код выше как проницаемым ответ я написал использовал этот

android:windowSoftInputMode="stateVisible|adjustResize"/> 

Но когда-то у вас есть, чтобы заставить его с помощью кода в OnCreate() метод:

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); 

Вот исправление, и вот doc на этом.

Установка должна быть одним из значений, перечисленных в следующей таблице, или сочетание одного «состояния ...» значение плюс одно значение «настроить ...». Установка нескольких значений в любой группе - несколько значений «состояние ...», например - имеет неопределенные результаты. Отдельные значения разделяются на вертикальной полосой (|). Например:

Но я не читал вопрос OP правильно, и hes scrollview не двигается. Для этого требуется элемент OnGlobalLayoutListener(), который добавляется в представление прокрутки.

final View activityRootView = findViewById(R.id.activityRoot); 
activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { 
@Override 
public void onGlobalLayout() { 
    Rect r = new Rect(); 
    //r will be populated with the coordinates of your view that area still visible. 
    activityRootView.getWindowVisibleDisplayFrame(r); 

    int heightDiff = activityRootView.getRootView().getHeight() - (r.bottom - r.top); 
    if (heightDiff > 100) { // if more than 100 pixels, its probably a keyboard... 
     ... do something here 
    } 
} 
}); 

Here are some awesome way to do it. Код выше от @Kachi.

+0

SA, это решение разрешает проблему с прокруткой, но мой нижний колонтитул по-прежнему растет с андроидом: windowSoftInputMode = "stateVisible | adjustResize", есть ли какой-либо способ прокрутки работает, а нижний колонтитул не поднимается? –

+0

@RafaelChinelatoDelNero пробовал только с Android: windowSoftInputMode = "adjustResize">? Это сработало для меня! –

+0

S A, когда я ставлю только «adjustResize», мой нижний колонтитул все еще поднимается, я не хочу этого поведения. –

Смежные вопросы