【发布时间】:2021-06-29 12:11:13
【问题描述】:
我在整个屏幕上有一个图像视图,右下角有一个按钮。
现在,我无法在按钮下方和右侧放置基准线。
我希望按钮从右侧“边缘”4.1%,从底部“边缘”4.1%,使用指南。
这是我的尝试。
如何解决?
<?xml version="1.0" encoding="utf-8"?>
<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"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView" />
<Button
android:layout_width="wrap_content"
android:layout_height="30dp"
android:id="@+id/button_try"
app:layout_constraintRight_toLeftOf="@+id/guideline_for_try_from_bottom"
app:layout_constraintBottom_toTopOf="@+id/guideline_for_try_from_bottom"/>
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline_for_try_from_bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintWidth_max="26dp"
app:layout_constraintWidth_min="15dp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintGuide_percent="0.041" />
它看起来像:
|
button 4.1% | END_OF_SCREEN
4.1% |
____________
BOTTOM_OF_SCREEN
【问题讨论】:
-
你必须为 right -- start/end 指定指南方向,对于底部:方向将是水平的,方向将是底部,分离两条指南,一条不足以对齐右侧和底部
标签: android android-constraintlayout constraintlayout-guideline