- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我点击 3 个编辑文本中的一个时,我的键盘出现并且 View 向上滚动一点。但是我的布局应该一直向上移动。我的 xml 文件:
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:id="@+id/scrollView"
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar"
app:layout_constraintVertical_bias="0.01999998">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="126dp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/padding_default"
android:padding="@dimen/padding_small"
android:paddingHorizontal="@dimen/padding_default"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="16dp" />
<EditText
android:id="@+id/instructionsEditText"
android:layout_width="match_parent"
android:layout_height="600dp"
android:layout_margin="@dimen/padding_default"
android:gravity="top|start"
android:padding="@dimen/padding_small"
android:paddingHorizontal="@dimen/padding_default"
app:layout_constraintTop_toBottomOf="@+id/amountPersonsEditText" />
<EditText
android:id="@+id/notesEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/padding_default"
android:padding="@dimen/padding_small"
android:paddingHorizontal="@dimen/padding_default"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/instructionsEditText"
tools:layout_editor_absoluteX="16dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
<android.widget.Button
android:id="@+id/saveInstructionsButton"
style="@style/buttonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/padding_default"
android:gravity="center"
android:imeOptions="actionDone"
android:text="@string/instructions_button_text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
我的安卓 list :
<activity
android:name=".ui.instructions.InstructionsActivity"
android:windowSoftInputMode="adjustResize"
android:screenOrientation="portrait" />
我也试过这个:
fun ScrollView.moveToTop() {
this.isFocusableInTouchMode = true
this.fullScroll(View.FOCUS_DOWN)
this.smoothScrollTo(0, bottom)
}
但是按钮在 ScrollView 之外,按钮底部应该在键盘顶部。
开始:
实际:
预期:
最佳答案
在 ScrollView 中添加以下代码:
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@+id/saveInstructionsButton"
底部按钮中的代码:
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
示例代码:
<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">
<ScrollView
android:id="@+id/scrollView"
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@+id/saveInstructionsButton">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/amountPersonsEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/padding_default"
android:padding="@dimen/padding_small"
android:paddingHorizontal="@dimen/padding_default"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="16dp"
android:focusableInTouchMode="true" />
<EditText
android:id="@+id/instructionsEditText"
android:layout_width="match_parent"
android:layout_height="600dp"
android:layout_margin="@dimen/padding_default"
android:gravity="top|start"
android:padding="@dimen/padding_small"
android:paddingHorizontal="@dimen/padding_default"
android:focusableInTouchMode="true"
app:layout_constraintTop_toBottomOf="@+id/amountPersonsEditText" />
<EditText
android:id="@+id/notesEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/padding_default"
android:padding="@dimen/padding_small"
android:paddingHorizontal="@dimen/padding_default"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/instructionsEditText"
tools:layout_editor_absoluteX="16dp"
android:focusableInTouchMode="true"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
<android.widget.Button
android:id="@+id/saveInstructionsButton"
style="@style/buttonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:imeOptions="actionDone"
android:text="@string/instructions_button_text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
list 文件代码:
<activity
android:name=".ui.instructions.InstructionsActivity"
android:windowSoftInputMode="adjustResize"
android:screenOrientation="portrait" />
以上代码的输出是:
关于android - 单击 EditText 时 View 不会一直向上滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69043158/
我有一个在 Android 市场上相当流行的应用程序,它允许数以万计的用户按下一个按钮并向它发出语音命令。然后我就可以做很多不同的事情,比如给他们提供当前的天气预报等等...... 无论如何,我的应用
令人惊讶的是,标题基本上解释了它。我们有一个我们的客户制作的页面,我们正在重新创建该页面。 页面高度会一直增加,直到(我假设是这样)浏览器达到它的极限。我已经尝试过 Firebug 和 W3 验证器,
我是 react-native 的新手,试图创建我自己的组件,但它一直显示一个空屏幕。 这是我的组件代码 class BoxComponent extends Component { cons
我正在为我的 PHP 元素创建一个非常简单的博客,但遇到了一个简单的问题。我无法让我的页眉图像一直 float 。我有一个横幅,左边有一些文字,我有一个 1px 的切片,在可以选择的任何分辨率的宽度上
为什么我可以在另一个 Controller 的 View 中访问一个 Controller 的辅助方法?有没有办法在不破解/修补 Rails 的情况下禁用它? 最佳答案 @George Schreib
我正在使用带有最新 ADT 插件的 Eclipse Kepler SP2。每隔一分钟 Eclipse 就会说“为 Android 4.4.2 加载数据”并阻止我想做的一切。我在不同的文件夹中有几个 E
我是一名优秀的程序员,十分优秀!