我有一个横向小屏幕的布局。我在布局的 TextView 中有一些文本...但它没有显示。我没有定义任何文本大小字体,也没有设置任何尺寸。然而,textview 的文本没有显示:
<LinearLayout android:layout_width="wrap_content"
android:id="@+id/text_container"
android:layout_height="wrap_content"
android:layout_above="@+id/relativeLayout"
android:layout_centerHorizontal="true"
android:layout_marginBottom="25dp">
<TextView
android:layout_width="match_parent"
android:text="20:00"
android:layout_height="match_parent"
/>
</LinearLayout>
然而,TextView 是空的...这是一张显示设计布局屏幕的图像:
这里你可以看到文字设置的很清楚:
为什么文本不显示?这非常奇怪,我已经尝试了很多东西,但问题仍然存在。我试过:
- 重启 Android Studio
- 刷新设计 View
- 构建 -> 清理项目
- 构建 -> 重建项目
然而,问题依然存在。感谢您协助完成此问题。
奇怪的是,这只适用于布局小景观。它适用于常规布局和小型布局。这是相同的代码...
最佳答案
我猜你错过了 textColor
。只需添加这个
android:textColor="#00FF00"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
原因
android:layout_marginBottom="25dp"
layout_marginBottom 是这里的主要罪魁祸首。您的小设备中没有大小 25dp
。这就是问题的原因。
关于android - 向布局添加文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34283864/