我编码这个布局:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:orientation="horizontal"
android:paddingEnd="10dp">
<TextView
style="@style/textStyle.Medium.black"
android:layout_width="79dp"
android:layout_height="wrap_content"
android:gravity="center|start"
android:minHeight="42dp"
android:adjustViewBounds="true"
android:text="姓名"/>
<TextView
android:id="@+id/tv_name"
style="@style/textStyle.Medium.subTitle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center|end"
android:minHeight="42dp"
android:adjustViewBounds="true"
android:text="暂无"/>
</LinearLayout>
但我设置的文字很长,例如:
<TextView
android:id="@+id/tv_name"
style="@style/textStyle.Medium.subTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center|end"
android:minHeight="42dp"
android:adjustViewBounds="true"
android:text="暂无+++++++++++++++
+++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++
+++++++++++++++"/>
它会:
内容不会全部显示,它会导致错位。这就像第一个TextView的minHeight属性一样。但我不明白为什么?
抱歉,我的英语很差!
答案 0 :(得分:0)
试试这个
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:orientation="horizontal"
android:paddingEnd="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:gravity="center|start"
android:minHeight="42dp"
android:text="姓名" />
<TextView
android:id="@+id/tv_name"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:gravity="center|end"
android:minHeight="42dp"
android:text="暂无+++++++++++++++
+++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++
+++++++++++++++" />
</LinearLayout>