【问题标题】:TextView in LinearLayout not showing text portion but shows image fineLinearLayout 中的 TextView 不显示文本部分但显示图像很好
【发布时间】:2013-07-27 09:24:18
【问题描述】:

我在线性布局中有两个 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>

【问题讨论】:

标签: android android-layout textview


【解决方案1】:

我在我的 Galaxy S3 上测试了你的代码,运行良好,我可以看到文本。

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

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

【讨论】:

    猜你喜欢
    • 2011-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多