android - ScrollView 在 ConstraintLayout 和 viewPage 中不起作用
问题描述
我正在使用约束布局我试图在其中使用滚动视图,尤其是当键盘出现在屏幕上时。当键盘出现时对齐完全改变并且滚动视图不出现
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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_height="match_parent"
android:layout_width="match_parent"
android:fillViewport="true"
tools:context=".Activity.HomeActivity">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/Constrain_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg"
android:orientation="vertical"
>
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/toolbar_gradient"
android:minHeight="?attr/actionBarSize"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/button3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<androidx.viewpager.widget.ViewPager
android:id="@+id/pager"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/button3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tabLayout"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</androidx.constraintlayout.widget.ConstraintLayout>
解决方案
android:windowSoftInputMode="adjustPan"
在清单的活动标签中使用它
例子:
<activity
android:name=".activities.MainActivity"
android:windowSoftInputMode="adjustPan" />
推荐阅读
- javascript - 创建新的猫鼬子文档并附加到现有的父文档
- node.js - Discord JS v13 嵌入欢迎消息错误
- firebase - 是否可以根据用户角色从启动屏幕导航或推送到管理屏幕或用户屏幕?
- sql - 如何获取嵌套在 jsonb 数组中的对象?
- .net - git clone :此应用程序需要以下 .NET Framework 版本之一:.NET framework,Version =v4.7.2
- javascript - 将数组中的元素显示到站点中不起作用
- javascript - 如何使用 switch 函数解决错误 - JavaScript
- wordpress - Wordpress,图像渲染之前的过滤器/操作?
- json - 从 Java 或 Python 代码中调用 VS 代码扩展
- git - 有没有办法开发自定义 Git 比较扩展?