gpt4 book ai didi

Android - ConstraintLayout - 大文本的椭圆末尾

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:10:17 25 4
gpt4 key购买 nike

我需要一些有关 Android 布局的帮助。我有以下代码:

<?xml version="1.0" encoding="utf-8"?>
<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="wrap_content">

<android.support.constraint.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5" />

<android.support.constraint.Guideline
android:id="@+id/guideline2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.725" />

<TextView
android:id="@+id/data_field_1_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="10dip"
android:layout_marginTop="10dip"
app:layout_constraintLeft_toLeftOf="@id/guideline"
app:layout_constraintRight_toLeftOf="@id/guideline2"
app:layout_constraintTop_toTopOf="parent"
tools:text="ACTIVE" />

<TextView
android:id="@+id/data_field_1_value"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="15dip"
android:layout_toEndOf="@id/data_field_1_name"
app:layout_constraintBaseline_toBaselineOf="@id/data_field_1_name"
app:layout_constraintLeft_toLeftOf="@id/guideline2"
app:layout_constraintRight_toRightOf="parent"
tools:text="1750" />

<TextView
android:id="@+id/data_field_2_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="10dip"
android:layout_marginTop="8dip"
app:layout_constraintLeft_toLeftOf="@id/guideline"
app:layout_constraintRight_toLeftOf="@id/guideline2"
app:layout_constraintTop_toBottomOf="@id/data_field_1_name"
tools:text="ACTIVE" />

<TextView
android:id="@+id/data_field_2_value"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="15dip"
android:layout_toEndOf="@id/data_field_2_name"
app:layout_constraintBaseline_toBaselineOf="@id/data_field_2_name"
app:layout_constraintLeft_toLeftOf="@id/guideline2"
app:layout_constraintRight_toRightOf="parent"
tools:text="1750" />


<TextView
android:id="@+id/data_field_3_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="10dip"
android:layout_marginTop="8dip"
app:layout_constraintLeft_toLeftOf="@id/guideline"
app:layout_constraintRight_toLeftOf="@id/guideline2"
app:layout_constraintTop_toBottomOf="@id/data_field_2_name"
tools:text="ACTIVE" />

<TextView
android:id="@+id/data_field_3_value"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="15dip"
android:layout_toEndOf="@id/data_field_3_name"
app:layout_constraintBaseline_toBaselineOf="@id/data_field_3_name"
app:layout_constraintLeft_toLeftOf="@id/guideline2"
app:layout_constraintRight_toRightOf="parent"
tools:text="1750" />

<TextView
android:id="@+id/value"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="15dip"
android:layout_marginStart="15dip"
android:textSize="25sp"
app:layout_constraintBaseline_toBaselineOf="@id/data_field_2_name"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
tools:text="17.40" />

<ImageView
android:id="@+id/flag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="0dp"
android:layout_marginTop="2dp"
android:src="@drawable/ic_launcher_background"
app:layout_constraintEnd_toEndOf="@+id/unit"
app:layout_constraintStart_toStartOf="@+id/unit"
app:layout_constraintTop_toTopOf="parent" />

<android.support.v7.widget.AppCompatTextView
android:id="@+id/unit"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="2dp"
android:gravity="center_horizontal"
app:layout_constraintBaseline_toBaselineOf="@id/value"
app:layout_constraintStart_toEndOf="@+id/value"
tools:text="KG" />

<TextView
android:id="@+id/label"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="15dip"
app:layout_constraintBaseline_toBaselineOf="@id/data_field_3_name"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/guideline"
tools:text="TOTAL" />
</android.support.constraint.ConstraintLayout>

输出是:enter image description here

我的问题是:如果主值 (17.40) 太大,该值应该“省略”以结束,但它会覆盖“Activity ”文本。

大文本的输入是:enter image description here

我需要这样的东西来获得大值(value): enter image description here

PS:单位和标志应该始终显示在主值的末尾。

你能帮我提点建议吗?我尝试了很多想法,但没有找到解决方案。

最佳答案

  1. 将子布局宽度设置为 0dp

android:layout_width="0dp"

  1. 设置 Right_toRightOfLeft_toRightOf

app:layout_constraintLeft_toRightOf="@+id/listingImageView" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent"

关于Android - ConstraintLayout - 大文本的椭圆末尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45983394/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com