如何将3个按钮中心对齐并使用ConstraintLayout?
为了清楚起见,我想将这个简单的布局结构转换为平面UI ConstraintLayout
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
我已经获得了如下最近的解决方案
<android.support.constraint.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">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@+id/button2"
/>
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
tools:layout_conversion_absoluteHeight="48dp"
tools:layout_conversion_absoluteWidth="88dp"
tools:layout_conversion_absoluteX="148dp"
tools:layout_conversion_absoluteY="259dp"
app:layout_constraintBottom_toTopOf="@+id/button3"
app:layout_constraintTop_toBottomOf="@+id/button"
app:layout_constraintRight_toRightOf="parent"/>
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
tools:layout_conversion_absoluteHeight="48dp"
tools:layout_conversion_absoluteWidth="88dp"
tools:layout_conversion_absoluteX="148dp"
tools:layout_conversion_absoluteY="307dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button2"
app:layout_constraintRight_toRightOf="parent"/>
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
但很明显,您可以看到获得的输出与所需的输出不匹配.我不希望3个按钮之间有任何边距或空格,我想要的是将这3个按钮垂直居中对齐,就像它们处于LinearLayout垂直方向一样.
我有一个现有的 android studio 项目,我想在我的项目中使用 jetpack compose。文档说明了如何使用 jetpack compose 创建新项目,但如何将其与现有项目一起使用?
android google-play-services fusedlocationproviderapi android-fusedlocation
如果您更新从版本扑SDK v1.12.13后任何版本v1.13.8,您将收到有关textTheme使用几个警告信息。例如,下面给出了其中之一。
信息:body2 已弃用,不应使用。这是 2014 版材料设计中使用的术语。现代术语是 bodyText1。此功能在 v1.13.8 之后被弃用。
新版本有哪些变化?如何迁移?
有人可以告诉我如何将菜单抽屉集成到 Row 小部件中而不是 Scaffold 小部件中吗?类似于 Gmail 的应用程序(使用抽屉图标搜索)。