ConstraintLayout - 连接小组件与障碍物的问题。

问题描述 投票:0回答:1

我遇到了一个奇怪的问题。layout.xml

<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">

    <TextView
        android:id="@+id/textView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="wwwwwwwwwwwwwwwwwww" />

    <TextView
        android:id="@+id/textView5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="wedwdwqefwerfwe"
        tools:layout_editor_absoluteX="0dp"
        tools:layout_editor_absoluteY="51dp" />

    <androidx.constraintlayout.widget.Barrier
        android:id="@+id/barrier"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:barrierDirection="end"
        app:constraint_referenced_ids="textView5,textView4"
        tools:layout_editor_absoluteX="411dp" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button"
        tools:layout_editor_absoluteX="275dp"
        tools:layout_editor_absoluteY="155dp" />
</androidx.constraintlayout.widget.ConstraintLayout>

我想把一个小部件连接到我的屏障上。问题是,当我试图将 END 我的小部件的 barrier,没有连接(我做不到,我拖拽没有成功).这是我试图连接的图片,但不可能。enter image description here

android xml android-layout android-constraintlayout constraintlayout-barrier
1个回答
1
投票

你的问题仍然不清楚,但据我所知,你无法将视图与障碍连接起来,对吗?

enter image description here

    <?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">

    <androidx.appcompat.widget.AppCompatTextView
        android:id="@+id/textView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="wwwwwwwwwwwwsdfdsfw"
        android:textSize="@dimen/_15ssp"
        app:layout_constraintEnd_toStartOf="@+id/barrier"
        app:layout_constraintStart_toStartOf="parent" />

    <androidx.appcompat.widget.AppCompatTextView
        android:id="@+id/textView5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/_20sdp"
        android:text="wedwdwqefwerfwe"
        android:textSize="@dimen/_15ssp"
        app:layout_constraintEnd_toStartOf="@+id/barrier"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView4" />

    <androidx.constraintlayout.widget.Barrier
        android:id="@+id/barrier"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:barrierDirection="end"
        app:constraint_referenced_ids="textView5,textView4"
        tools:layout_editor_absoluteX="411dp" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@+id/barrier"
        tools:layout_editor_absoluteX="275dp"
        tools:layout_editor_absoluteY="155dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
© www.soinside.com 2019 - 2024. All rights reserved.