android - 如何使 Jetpack compose 元素出现在 android 的键盘顶部?
问题描述
在 XML 中让按钮粘在屏幕底部并在弹出时粘在键盘上非常简单,我们可以做这样的事情
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
//the ui views
<TableLayout
android:id="@+id/m_table_menu"
style="@style/table_layout_style">
<View style="@style/view_style" />
<TableRow style="@style/table_row_button_style">
//This button sticks to the bottom of the screen or to the keyboard when its open
<Button
android:id="@+id/save_user_name"
style="@style/green_bottom_sticky_button"
android:background="@drawable/green_disabled_ripple_rectangular_button"
android:enabled="false"
android:text="@string/next" />
</TableRow>
</TableLayout>
</RelativeLayout>
我们将如何在 Jetpack compose 中复制它?
解决方案
我不确定 XML 是如何工作的,因为它没有重力或高度的定义。
但是,如果您希望视图始终位于列的底部,您可以制作一个单独Box
的按钮,并提供最大尺寸和内容重力Bottom
推荐阅读
- flutter - 当用户单击平面按钮时如何在颤动中显示奖励视频
- java - Tomcat 7.0 版本上的 spring boot 2.2.1 Web 应用程序部署问题
- maven - 执行 org.apache.maven.plugins:maven-site-plugin:3.7.1:site:org/apache/maven/reporting/AbstractMavenReport 时缺少必需的类
- c - C程序执行成功显然取决于文件名
- java - 如何解决 PDFBox 中没有 unicode 映射错误?
- javascript - 使用 AJAX 或 jquery 登录到另一个站点而不重新加载页面
- r - 熔化 data.table 时如何指定一个空的 id.vars 向量?
- c++ - 为什么将数据从文本文件移动到数组时无法获得正确的输出
- mysql - 将数据插入到由联结表连接的 2 个表中
- r - 有没有办法在不打印 R 版本 ... 消息的情况下启动 R?