android – 添加文本到布局?

我有一个横向小屏幕的布局.我在布局中的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是空的……这是一个显示设计布局屏幕的图像:

enter image description here

在这里你可以看到文字清楚地设置:

enter image description here

为什么文字没有出现?这是非常奇怪的,我已经尝试了很多东西,但问题仍然存在.我试过了:

>重新启动Android Studio
>刷新设计视图
>构建 – >清洁项目
>构建 – >重建项目

然而,问题仍然存在.感谢您协助我完成此问题.

奇怪的是,这只适用于布局小景观.它在常规布局和小布局中工作正常.这是相同的代码……

解决方法:

我猜你错过了textColor.只需添加它

android:textColor="#00FF00"
android:layout_width="fill_parent"
android:layout_height="wrap_content"

原因

 android:layout_marginBottom="25dp"

layout_marginBottom是这里的主要罪魁祸首.你的小设备中没有25dp的大小.这就是为什么有问题.

相关文章

Android 如何解决dialog弹出时无法捕捉Activity的back事件 在...
Android实现自定义带文字和图片的Button 在Android开发中经常...
Android 关于长按back键退出应用程序的实现最近在做一个Andr...
android自带的时间选择器只能精确到分,但是对于某些应用要求...