android - 如何让 wrap_content TextView 停留在 ConstraintLayout 上 Button 的左侧?

标签 android android-layout android-appcompat android-constraintlayout

我有这样的布局:

<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"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="com.constraintsample.MainActivity"
    tools:showIn="@layout/activity_main">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World! Hello World! Hello World! Hello World! Hello World! Hello World! Hello World! Hello World! Hello World! Hello World! Hello World! Hello World! "
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toLeftOf="@+id/button"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.0"/>
    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button with some text"
        app:layout_constraintRight_toRightOf="parent"/>
</android.support.constraint.ConstraintLayout>

最后看起来像这样:

enter image description here

但我希望在继续使用 wrap_content 的同时将文本留在按钮的左侧。我怎样才能做到这一点?

谢谢。

最佳答案

您的布局很好,只需将 android:layout_width="0dp" 设置为您的 textView

关于android - 如何让 wrap_content TextView 停留在 ConstraintLayout 上 Button 的左侧?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45447302/

相关文章:

安卓内联 Activity

php - 如何使用 FCM 使用 php 脚本向多个设备发送推送通知?

android - 我在 Android Studio 中使用 ActionBarActivity 有一些问题

java - Android ActionBar 发出不同的 API <> 21

java - 异步任务未加载数据

java - 在 fragment 和 Activity 之间交换数据 - NullPointerException

java - 如何延迟页面或 sleep 线程直到下载过程或进度条完成

Listview + Gridview 的 Android Studio 布局预览

Android 支持多分辨率和多布局文件夹

android - 从支持库添加 Android AppCompat ActionBar