gpt4 book ai didi

Android TextView 在屏幕右侧被截断

转载 作者:行者123 更新时间:2023-11-30 03:34:48 25 4
gpt4 key购买 nike

以下 xml 中的日期 TextView 在屏幕右侧被截断。我该如何解决这个问题?

我也不确定我这样做是否正确,但加密和签名的 ImageViews 永远不会同时出现,它要么是要么。

<LinearLayout
android:id="@+id/date_container"
android:layout_width="80dip"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="@dimen/date_margin_top"
android:orientation="horizontal"
>
<ImageView
android:id="@+id/encrypted"
android:layout_width="36dip"
android:layout_height="16dip"
android:layout_gravity="top"
android:src="@drawable/badge_encrypted" />
<ImageView
android:id="@+id/signed"
android:layout_width="36dip"
android:layout_height="16dip"
android:layout_gravity="top"
android:src="@drawable/badge_signed" />
<ImageView
android:id="@+id/paperclip"
android:layout_width="36dip"
android:layout_height="16 dip"
android:layout_gravity="top"
android:src="@drawable/ic_badge_attachment" />
<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/date_font_size"
android:text="@string/long_string"
android:lines="1" />
</LinearLayout>

最佳答案

您可以将宽度设置为 match_parent 并添加 Layout_weight,而不是设置固定宽度:

     <LinearLayout
android:id="@+id/date_container"
android:layout_width="80dip"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="@dimen/date_margin_top"
android:orientation="horizontal"
>
<ImageView
android:id="@+id/encrypted"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="16dip"
android:layout_gravity="top"
android:src="@drawable/badge_encrypted" />
<ImageView
android:id="@+id/signed"
android:layout_width="match_parent"
android:layout_height="16dip"
android:layout_weight="1"
android:layout_gravity="top"
android:src="@drawable/badge_signed" />
<ImageView
android:id="@+id/paperclip"
android:layout_width="match_parent"
android:layout_height="16dip"
android:layout_weight="1"
android:layout_gravity="top"
android:src="@drawable/ic_badge_attachment" />
<TextView
android:id="@+id/date"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="wrap_content"
android:textSize="@dimen/date_font_size"
android:text="@string/long_string"
android:lines="1" />
</LinearLayout>

但这取决于你想要什么。通常,您必须为多屏幕支持定义不同的布局资源。对于这个示例,您还必须为每个 imageView 设置 scaleType,以正确的方式缩放每个资源。

关于Android TextView 在屏幕右侧被截断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16779609/

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