3

У меня есть это Floating Action Button (GitHub link), и когда я открываю (программную) клавиатуру, плавающая кнопка действия скрывается за клавиатурой.Перемещение плавающей кнопки действия над клавиатурой

Есть ли способ, которым я могу нажать его над клавиатурой?

Edit:

tab_random.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <View 
     android:layout_width="match_parent" 
     android:layout_height="156dp" 
     android:background="@color/primary_color" 
     /> 

    <EditText 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/from" 
     android:inputType="number" 
     android:imeOptions="actionNext" 
     android:layout_centerHorizontal="true" 
     android:hint="From" 
     android:paddingStart="5dp" 
     android:textColor="#FFF" 
     android:fontFamily="sans-serif-light" 
     android:textSize="44sp" 
     android:backgroundTint="@color/fab_ripple" 
     android:layout_marginStart="10dp" 
      /> 

    <EditText 
     android:textSize="44sp" 
     android:layout_marginStart="10dp" 
     android:paddingStart="5dp" 
     android:fontFamily="sans-serif-light" 
     android:layout_centerHorizontal="true" 
     android:layout_below="@+id/from" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:hint="To" 
     android:inputType="number" 
     android:imeOptions="actionSend" 
/> 
</RelativeLayout> 

activity_main.xml

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:fab="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    tools:context="activity.MainActivity"> 

    <include 
     android:id="@+id/toolbar" 
     layout="@layout/tool_bar" /> 

    <slidingModel.SlidingTabLayout 
     android:layout_below="@+id/toolbar" 
     android:id="@+id/tabs" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:elevation="4dp" 
     android:background="@color/primary_color" 
     /> 

    <android.support.v4.view.ViewPager 
     android:layout_below="@id/tabs" 
     android:id="@+id/pager" 
     android:layout_height="wrap_content" 
     android:layout_width="match_parent" 

     /> 

    <com.melnykov.fab.FloatingActionButton 
     android:id="@+id/fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom|end" 
     android:layout_margin="16dp" 
     fab:fab_colorNormal="@color/fab_normal" 
     fab:fab_colorPressed="@color/fab_pressed" 
     fab:fab_colorRipple="@color/fab_ripple" 
     android:layout_marginLeft="16dp" 
     android:layout_marginRight="16dp" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentEnd="true" /> 

</RelativeLayout> 
+0

Я думаю, что это ваша проблема с макетом. –

+1

Я выложу свой Activity_main –

+0

Добавил ли @Raj ответ. Попробуйте свой путь –

ответ

1

Ваше расположение, как это прямо сейчас:

<Relative Layout> 
    <View/> 
    <EditText/> 
    <other stuff.../> 
</RelativeLayout> 

Вы должны добавить Scrollview внутри тегов RelativeLayout. Кроме того, scrollviews не нравится иметь более одного прямого дочернего представления, поэтому вам понадобится Relativelayout внутри scrollview. Итак, ваш макет будет выглядеть следующим образом:

<RelativeLayout> (this was already here) 
    <ScrollView> (this is new) 
     <RelativeLayout> (this is also new) 
      <View, EditText, Etc. in here/> (this is what used to be inside that original relative layout.) 
     </RelativeLayout> (closing up the new Relativelayout) 
    </ScrollView> (closing the new Scrollview) 
</RelativeLayout> (closing the original Relative Layout.) 
+0

FAB по-прежнему стоит за клавиатурой :( –

+0

отправил мой Activity_main, если он помогает –

+0

выглядит так, как будто все, что вам нужно сделать, это применить это исправление к макету activity_main вместо того, что бы это ни было. Поместите прокрутку вокруг всей страницы, кроме самой – MrPlow

0

Решение может быть положить всю раскладку внутри ScrollView.

+0

Как я могу это сделать? Я разместил свой макет, и вы можете сказать мне, как это сделать. –

0

ли это

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<ScrollView 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<View 
    android:layout_width="match_parent" 
    android:layout_height="156dp" 
    android:background="@color/primary_color" 
    /> 

<EditText 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/from" 
    android:inputType="number" 
    android:imeOptions="actionNext" 
    android:layout_centerHorizontal="true" 
    android:hint="From" 
    android:paddingStart="5dp" 
    android:textColor="#FFF" 
    android:fontFamily="sans-serif-light" 
    android:textSize="44sp" 
    android:backgroundTint="@color/fab_ripple" 
    android:layout_marginStart="10dp" 
     /> 

<EditText 
    android:textSize="44sp" 
    android:layout_marginStart="10dp" 
    android:paddingStart="5dp" 
    android:fontFamily="sans-serif-light" 
    android:layout_centerHorizontal="true" 
    android:layout_below="@+id/from" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:hint="To" 
    android:inputType="number" 
    android:imeOptions="actionSend" 
    /> 
    </ScrollView> 
    </RelativeLayout> 

Поскольку ваши детали теперь внутри Scrollview они будут прокручивать.

+0

FAB все еще стоит за клавиатурой, когда я помещаю этот код. –

+0

Отправлено my activity_main.xml –

1

TRU ДЕЛАТЬ ЭТО. iT WORK FOR ME.

Добавить stateVisible | adjustPan К ВАШЕЙ ДЕЯТЕЛЬНОСТИ В ВАШЕМ ПРОЯВЛЕНИИ.

<activity 
android:name="com.comapny.applicationname.activityname" 
android:screenOrientation="portrait" 
android:windowSoftInputMode="stateVisible|adjustPan"/> 
+0

Не помогло мне вообще :( –

+0

Вы хотите отобразить его поверх клавиатуры или немного сдвинуть его, чтобы он мог быть vissbile ?. Если вы заглянете на клавиатуру, – RajSharma

+0

Я хочу отобразить его на клавиатуре, чтобы он был виден. –

0

Попробуйте с этим:

activity_main.xml

<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
xmlns:fab="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" 
tools:context="activity.MainActivity"> 

<include 
    android:id="@+id/toolbar" 
    layout="@layout/tool_bar" /> 

<slidingModel.SlidingTabLayout 
    android:layout_below="@+id/toolbar" 
    android:id="@+id/tabs" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:elevation="4dp" 
    android:background="@color/primary_color" 
    /> 

<android.support.v4.view.ViewPager 
    android:layout_below="@id/tabs" 
    android:id="@+id/pager" 
    android:layout_height="wrap_content" 
    android:layout_width="match_parent" 

    /> 

<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="right|bottom" 
     android:layout_margin="@dimen/fab_margin" /> 

</ScrollView> 

Все, что я сделал это положить ФАБ внутри ScrollView.

1

У меня была аналогичная проблема, последующее предложение от @MrPlow, но где он добавил Scrollview внутри исходного RelativeLayout, а затем добавил еще один RelativeLayout внутри ScrollView (чтобы сохранить структуру форматирования), я просто завернул весь макет в ScrollView, и он «просто сработал». Окончательный вариант для OP будет следующим:

<Scrollview> 
    <RelativeLayout> 
     <View/> 
     <EditText/> 
     <other stuff.../> 
    </RelativeLayout> 
</Scrollview> 
Смежные вопросы