gpt4 book ai didi

android - LinearLayout 中的 TextView 不显示文本部分但显示图像正常

转载 作者:太空狗 更新时间:2023-10-29 15:09:47 25 4
gpt4 key购买 nike

我有两个线性布局的 TextView。第一个 Textview,称之为 pen_name,有一张图片;第二个 TextView 只是文本。在图形布局上,一切都显示正常。但是当我在真实设备上运行该应用程序时,显示的是第一个 TextView 的图像而不是文本。第二个 TextView 工作正常。这是代码。

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >

<TextView
android:id="@+id/pen_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:drawableLeft="@drawable/a_pen"
android:drawablePadding="3dp"
android:gravity="center_vertical"
android:text="my_pseudonym"
android:textColor="#1083f0"
android:textSize="12sp"
android:textStyle="bold" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginLeft="2dp"
android:gravity="center_vertical"
android:text="Writer"
android:textColor="#1083f0"
android:textSize="12sp" />
</LinearLayout>

最佳答案

我在我的 Galaxy S3 上测试了您的代码,运行完美,我可以看到文本。

屏幕上可绘制对象的大小取决于原始文件中图像的大小,当使用带有 TextView 的复合可绘制对象时,这意味着您无法真正控制可绘制对象的大小,如果它太宽,它可能只是掩盖文字。

您可以尝试使用较小的图像,或者为较小的屏幕尺寸提供较小的图像。

关于android - LinearLayout 中的 TextView 不显示文本部分但显示图像正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17896268/

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