如何解决TextView与另一个textview重叠
我希望文本显示在名称的右侧,但是如果名称太大,则右侧的文本将无法显示在屏幕上。我使用了以下解决方案,但它会导致第一个textview超出其中的文本大小。
我所拥有的: screenshot
我想要什么: concept
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="true"
android:orientation="horizontal"
android:weightSum="1">
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignWithParentIfMissing="true"
android:layout_weight="1"
android:fontFamily="@font/montserrat"
android:singleLine="true"
android:text="1"
android:textColor="@color/colorText"
android:textSize="20sp" />
<TextView
android:id="@+id/readed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center_vertical"
android:layout_marginStart="10dp"
android:background="@drawable/back_new"
android:fontFamily="@font/montserrat"
android:gravity="center"
android:keepScreenOn="true"
android:paddingHorizontal="5dp"
android:paddingVertical="3dp"
android:singleLine="true"
android:text="554"
android:textColor="@color/colorWhite"
android:textSize="18sp" />
</LinearLayout>
解决方法
只需在两个textViews中删除android:weighSum =“ 1”和android:layout_weight属性
enter code here<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="true"
android:orientation="horizontal">
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignWithParentIfMissing="true"
android:fontFamily="@font/montserrat"
android:singleLine="true"
android:text="3"
android:textColor="@color/colorText"
android:textSize="20sp" />
<TextView
android:id="@+id/readed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center_vertical"
android:layout_marginStart="10dp"
android:background="@drawable/back_new"
android:fontFamily="@font/montserrat"
android:gravity="center"
android:keepScreenOn="true"
android:paddingHorizontal="5dp"
android:paddingVertical="3dp"
android:singleLine="true"
android:text="554"
android:textColor="@color/colorWhite"
android:textSize="18sp" />
</LinearLayout>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。