【发布时间】:2019-05-07 14:50:33
【问题描述】:
我有这个 XML:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
style="@style/Icon"
tools:background="@color/Black54Opacity" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:baselineAligned="false">
<LinearLayout
android:layout_width="0dp"
android:layout_height="24dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="24dp"
android:ellipsize="end"
android:includeFontPadding="false"
android:maxLines="1"
android:padding="0dp"
android:textColor="@android:color/black"
android:textSize="20sp"
tools:text="LONG LONG LONG" />
<TextView
android:layout_width="wrap_content"
android:layout_height="18dp"
android:minWidth="18dp"
tools:text="2342"
tools:visibility="visible" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="24dp"
android:gravity="center_vertical|end"
android:textColor="4CAF50"
tools:text="EDIT" />
</LinearLayout>
</LinearLayout>
当我在我的第一个 TextView 中插入一个短文本时 - 我没有问题。
当我在第一个 textView 中插入长文本时 - 我的第二个 TextView 移动到了第三个 TextView 下。
我希望第一个 TextView 中的文本可以调整到那个点,这样其他两个 TextView 就不会改变它们的大小。
第一个TextView中的长文本最后被椭圆化了。 第二个 TextView 必须始终压在第一个 TextView 的左侧。
【问题讨论】:
-
你能给我看看你的 XML 布局屏幕吗?
-
@Niceumang 我用图片更新了我的问题。
-
@Sergey 尝试为您的第二个 TextView 添加权重
-
重量对我没有帮助,因为我不能更改第二个 TextView 的宽度。第二个 TextView 必须绑定到第一个 TextView 的右侧。
标签: android xml position android-linearlayout