android-constraintlayout 相关问题

Android支持存储库中提供的一种新类型布局,构建于灵活约束系统之上,标记视图相对于彼此的位置。

自定义小部件不显示在布局中

我有一个我创建的自定义视图 TravelContactDetailsWidget 类:ConstraintLayout { 私人 lateinit var 绑定:TravelContactDetailsWidgetBinding 构造函数(上下文:上下文):...

回答 0 投票 0

Elevation 不适用于 ConstraintLayout 中的 include 标签

Elevation 在 ConstraintLayout 中不起作用,并且按钮始终显示在全屏进度的前面...... 这是一个示例代码,原始代码要大得多所以请不要建议使用 FrameLay ...

回答 0 投票 0

如何在 ConstraintLayout 中以固定边距和动态宽度均匀放置视图?

我想像这样设置 ConstraintLayout: 我需要有固定的左右约束,大小尺寸比为 1:1 和宽度将是灵活的,它会调整到 s 的实际宽度......

回答 2 投票 0

Constraint Compose中有重力参数吗?

在 Android XML 方法中,我们曾经有一个重力参数,我们可以使用该参数在宽度指定为 0dp 的约束布局内指定项目的重力。在这种情况下

回答 0 投票 0

MotionLayout 仅在第一次 ACTION_UP 后动画

我对 MotionLayout (XML) 有疑问。我在 motionlayout 中创建水平回收视图。我已经拦截了 OnTouch,但只有在第一次 ACTION_UP 之后转换才有效。所以第一次...

回答 0 投票 0

无法为约束布局导入 createRefs()

我的进口 它要求我导入焦点请求,但我想使用 createRef() 作为约束布局参考 我正在使用这个版本:“androidx.constraintlayout:constraintlayout-compose:1...

回答 2 投票 0

如何使用 ConstraintLayout 将两个垂直 TextView 一侧的 ImageView 居中

我需要一个 ImageView 位于 2 个垂直 TextView 右侧的布局,如下所示: 我希望 ImageView 和 TextViews 都在父布局中居中,尽管 TextViews 应该在一起......

回答 0 投票 0

即使使用 layout_constraintDimensionRatio="1:1" in Kotlin, android studio,我的按钮也不是正方形

我正在尝试使用约束布局和指南制作一个应用程序。一切正常,除非我试图按下按钮。 这是显示问题所在的设计屏幕截图:我的按钮 ha...

回答 1 投票 0

Jetpack Compose 中的约束宽度/约束高度

如何在 Compose 中设置约束宽度/高度? 文本(“测试”,Modifier.constrainAs(文本){ 链接到( 开始 = parent.start, 顶部 = 按钮.底部, 结束 = parent.end, ...

回答 3 投票 0

根据大小和图标在工具栏中居中或左对齐文本视图

我想处理 3 种在自定义工具栏(约束布局)中显示文本的情况。 如果文本很短,请将其放在中间 如果文本中等长度但它开始重叠图标 - 移动文本...

回答 3 投票 0

ConstraintLayout - marginEnd 无效

我正在尝试为视图设置结束边距属性,如下所示: 我正在尝试为视图设置结束边距属性,如下所示: <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto"> <TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Title" app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toStartOf="@+id/sub_title" android:layout_marginEnd="22dp" /> <TextView android:id="@+id/sub_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="subTitle" app:layout_constraintStart_toEndOf="@+id/title" app:layout_constraintTop_toTopOf="parent" /> </androidx.constraintlayout.widget.ConstraintLayout> 没有效果(预览画面): 当我为 marginStart TextView 设置 id:sub_title 而不是边距工作正常但我需要在 id:title TextView 上设置边距因为另一个原因 我可以通过为 id:title TextView 指定它来实现所需的边距吗? 如果“字幕”没有被约束到末尾,margin end 将没有效果。在您的案例中,您将边距开始设置为“副标题”: <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto"> <TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Title" app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toStartOf="@+id/sub_title" /> <TextView android:id="@+id/sub_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="subTitle" android:layout_marginStart="22dp" app:layout_constraintStart_toEndOf="@+id/title" app:layout_constraintTop_toTopOf="parent" /> </androidx.constraintlayout.widget.ConstraintLayout>

回答 1 投票 0

如何在 Jetpack Compose 中实现跨多个设备的一致设计

我正在做一个 Jetpack Compose 项目,并试图在 Sketch 应用程序设计的基础上实现像素完美的设计。但是,当我在两个不同的设备上运行该应用程序时,Pixel 6 Pro 和 Infix

回答 1 投票 0

constraintlayout wrapcontent 直到适合屏幕

我想制作recyclerview wrap_content。但我不希望“添加项目”按钮在添加项目时超出屏幕。如何解决这个问题? 我想制作recyclerview wrap_content。但我不希望“添加项目”按钮在添加项目时超出屏幕。如何解决这个问题? <?xml version="1.0" encoding="utf-8"?> <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" android:orientation="vertical"> <androidx.recyclerview.widget.RecyclerView android:id="@+id/recyclerView" android:layout_width="match_parent" android:layout_height="wrap_content" app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" app:layout_constraintBottom_toTopOf="@id/buttonAdd" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0" app:layout_constraintVertical_chainStyle="packed" tools:itemCount="16" tools:listitem="@layout/item_ver" /> <com.google.android.material.button.MaterialButton android:id="@+id/buttonAdd" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Add Item" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/recyclerView" /> </androidx.constraintlayout.widget.ConstraintLayout> 您只需要在app:layout_constrainedHeight="true"中添加androidx.recyclerview.widget.RecyclerView,这样您的代码将如下所示 <?xml version="1.0" encoding="utf-8"?> <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" android:orientation="vertical"> <androidx.recyclerview.widget.RecyclerView android:id="@+id/recyclerView" android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_constrainedHeight="true" app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" app:layout_constraintBottom_toTopOf="@id/buttonAdd" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0" app:layout_constraintVertical_chainStyle="packed" tools:itemCount="50" tools:listitem="@layout/item_ver" /> <com.google.android.material.button.MaterialButton android:id="@+id/buttonAdd" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Add Item" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/recyclerView" /> </androidx.constraintlayout.widget.ConstraintLayout>

回答 1 投票 0

安卓系统在一个反转布局里面做一个可调整大小的分屏。

我想在一个contraintlayout里面有一个分割器,能够改变2个图像视图的相对大小。例如:当拖动下面的双箭头时,应该根据......调整图像1图像2的大小。

回答 1 投票 1

有什么方法可以使用constraintlayout helper widget Flow编程?

我想使用constraint layout androidx.constraintlayout.helper.widget.Flow widget,但是当我搜索的时候没有找到任何关于使用flow widget的例子。我怎么能设置...

回答 1 投票 1

约束布局垂直对准中心--两个子视图。

我有两个TextViews, 一个在另一个上面. 我希望两个TextViews的垂直中间位置与ImageView的垂直中间位置相同。(就是这样,无论 ...

回答 3 投票 2

如何用view.GONE处理ConstraintLayout的水平& 垂直。

已经在约束中使用垂直和水平链来处理可见性消失。但它们并不能满足我想做的事情。我需要设置一个像这样的视图,例如:1 2 3 4 5 6 而且,对于......

回答 1 投票 0

在ViewPager wrap_content中的ConstraintLayout不能工作。

我创建了一个ViewPager,并把它放在ConstraintLayout里面。

回答 1 投票 2

如何让安卓的布局适合所有屏幕?[关闭]

我知道以前也有人问过类似的问题。但是我无法得到一个合适的解决我的问题的方法。我做了一个安卓应用,在google pixel screen上完美的运行。但在切换到...

回答 1 投票 0

如何让安卓的布局适合所有屏幕?[关闭]

我知道以前也有人问过类似的问题。但是我无法得到一个合适的解决我的问题的方法。我做了一个安卓应用,在google pixel screen上完美的运行。但在切换到...

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.