android中如何根据软键盘调整fragment中的屏幕大小?

问题描述 投票:0回答:0

当我尝试根据软键盘调整片段的屏幕大小时,我遇到了问题,屏幕没有在片段中调整,而是在活动中调整。我尝试了很多解决方案,但对我不起作用。

这是我的 Fragment 活动 xml 文件:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/btnAddCashReceive"
        android:orientation="vertical">

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

            <EditText
                android:id="@+id/edtAmountCashReceive"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginStart="13dp"
                android:layout_marginTop="@dimen/_10sdp"
                android:layout_marginEnd="12dp"
                android:layout_marginBottom="@dimen/_10sdp"
                android:drawableStart="@drawable/currency_rupee_24px"
                android:drawablePadding="@dimen/_10sdp"
                android:fontFamily="@font/poppins_medium"
                android:hint="0"
                android:imeOptions="actionDone"
                android:inputType="numberDecimal"
                android:textSize="42sp" />

            <com.google.android.material.chip.Chip
                android:id="@+id/chip100PercentCashReceive"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginHorizontal="@dimen/_10sdp"
                android:layout_marginStart="13dp"
                android:text="100%" />
        </LinearLayout>

    </LinearLayout>

    <com.google.android.material.button.MaterialButton
        android:id="@+id/btnAddCashReceive"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_marginStart="13dp"
        android:layout_marginEnd="12dp"
        android:text="Add" />
</RelativeLayout>

这是我的主要活动文件:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".BillActivity">

    <FrameLayout
        android:id="@+id/frame_full"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_alignParentTop="true"
        android:layout_alignParentBottom="true" />
</androidx.constraintlayout.widget.ConstraintLayout>
java android xml android-layout android-fragments
© www.soinside.com 2019 - 2024. All rights reserved.