小编Dar*_*ish的帖子

ConstraintLayout - 垂直或水平相邻的居中视图

如何将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 centering android-layout android-constraintlayout

15
推荐指数
2
解决办法
2万
查看次数

将 jetpack compose 添加到现有项目

我有一个现有的 android studio 项目,我想在我的项目中使用 jetpack compose。文档说明了如何使用 jetpack compose 创建新项目,但如何将其与现有项目一起使用?

android android-layout kotlin android-jetpack-compose

8
推荐指数
1
解决办法
5346
查看次数

如何从IntentService获取FusedLocation

  • 如何通过使用新的检索当前位置FusedLocation API从IntentService
  • 如何确保IntentService将从FusedLocation API接收所有 回调?即,如何同步获取位置对象

android google-play-services fusedlocationproviderapi android-fusedlocation

7
推荐指数
1
解决办法
2881
查看次数

body2 已弃用,不应使用。这是 2014 版材料设计中使用的术语。- 颤振中的警告消息

如果您更新从版本扑SDK v1.12.13后任何版本v1.13.8,您将收到有关textTheme使用几个警告信息。例如,下面给出了其中之一。

信息:body2 已弃用,不应使用。这是 2014 版材料设计中使用的术语。现代术语是 bodyText1。此功能在 v1.13.8 之后被弃用。

新版本有哪些变化?如何迁移?

flutter flutter-layout flutter-theme flutter-text

7
推荐指数
1
解决办法
5732
查看次数

导航导轨有颤动

材料设计指南包括一个称为导航导轨的组件。

如何使用颤振创建导航栏?

在此输入图像描述

material-design flutter flutter-layout flutter-navigation

5
推荐指数
2
解决办法
1万
查看次数

Flutter - 如何制作具有固定高度的自定义圆形标签指示器?

我想制作一个圆形的指示器,如下图所示。

在此处输入图片说明

我为它尝试了很多,但我不能让它像设计一样形状。

还告诉我如何使用颤振制作分段可扩展的列表视图? 列表视图的设计

flutter flutter-layout

4
推荐指数
1
解决办法
3546
查看次数

Flutter:如何像 Google Apps 一样使用 Drawer 实现浮动 SearchBar(自定义 AppBar)

有人可以告诉我如何将菜单抽屉集成到 Row 小部件中而不是 Scaffold 小部件中吗?类似于 Gmail 的应用程序(使用抽屉图标搜索)。

dart flutter

3
推荐指数
1
解决办法
4441
查看次数