#android #android-fragments #android-scrollview #window-soft-input-mode
#Android #android-фрагменты #android-scrollview #окно-режим программного ввода
Вопрос:
Я хочу, чтобы макет внутри моего фрагмента полностью прокручивался и помещался над программной клавиатурой всякий раз, когда открывается клавиатура. Но проблема в том, что макет даже не прокручивается, когда пользователь нажимает на клавиатуру. Он закрывает какую-то часть макета.
Я уже перепробовал много потоков SO, но, похоже, ни один из них не работает.
Вот макет активности:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<import type="android.view.View" />
<variable
name="viewModel"
type="com.abc.viewModel" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".home.HomeActivity">
<com.google.android.material.card.MaterialCardView
android:id="@ id/taskBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/_minus10sdp"
android:background="@android:color/white"
app:cardCornerRadius="@dimen/_5sdp">
</com.google.android.material.card.MaterialCardView>
<LinearLayout
android:id="@ id/appbar_practice"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimaryDark"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:paddingTop="@dimen/_10sdp">
</LinearLayout>
<FrameLayout
android:id="@ id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</layout>
Вот макет фрагмента:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:isScrollContainer="true"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:animateLayoutChanges="true"
android:background="@drawable/ic_bg_splash"
android:fillViewport="true"
android:paddingBottom="@dimen/_10sdp">
<LinearLayout
android:id="@ id/cardview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2">
<ImageButton
android:id="@ id/previous"
android:layout_width="@dimen/_30sdp"
android:layout_height="@dimen/_30sdp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/_20sdp"
android:background="@drawable/left"
android:padding="@dimen/_5sdp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2">
<ImageButton
android:id="@ id/next"
android:layout_width="@dimen/_30sdp"
android:layout_height="@dimen/_30sdp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="@dimen/_20sdp"
android:background="@drawable/right" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
Манифест:
<activity android:name=".home.MainActivity"
android:screenOrientation="landscape"
android:theme="@style/MaterialThemeHome"></activity>
Комментарии:
1. пробовал добавлять в ScrollView attr
android:fitsSystemWindows="true"
?2. @P.Juni пробовал, не работает