android:背景隐藏了我的文字

发布于 2024-09-15 11:30:50 字数 849 浏览 12 评论 0原文

我有一个小部件布局如下:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/widget_bg">
<TextView android:layout_height="fill_parent"
 android:layout_width="fill_parent"
 android:id="@+id/widgetText"
 android:text="@string/sWaitingForLocation"
 android:layout_marginLeft="4dip"
 android:layout_marginRight="4dip"
 android:layout_marginTop="4dip"
 android:layout_marginBottom="4dip"
 android:textStyle="bold"
 android:gravity="center">
</TextView>
</LinearLayout>

但是文本没有出现,就像隐藏在背景后面一样。

我的背景是 9patch png。 如果我使用 android:background="android:color/black" 它确实有效... 可以是我的png吗? (使用android工具draw9patch创建)

I have a widget layout as follow :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/widget_bg">
<TextView android:layout_height="fill_parent"
 android:layout_width="fill_parent"
 android:id="@+id/widgetText"
 android:text="@string/sWaitingForLocation"
 android:layout_marginLeft="4dip"
 android:layout_marginRight="4dip"
 android:layout_marginTop="4dip"
 android:layout_marginBottom="4dip"
 android:textStyle="bold"
 android:gravity="center">
</TextView>
</LinearLayout>

But the text doest appear, like it's hidden behind the background.

My background is a 9patch png.
It does work if I use android:background="android:color/black" ...
Can it be my png ? (created using android tool draw9patch)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

故事和酒 2024-09-22 11:30:50

这也可能是您问题的解决方案:Android 背景隐藏子视图文本
你能说一下你的 9 补丁有什么问题以及你是如何修复它的吗?

This might also be a solution for your problem: Android background hides child view text.
Can you say what was the problem with your 9-patch and how you fixed it?

执手闯天涯 2024-09-22 11:30:50

想到的可能性:

  • 文本颜色与您的可绘制颜色不同,是吗?
  • 有文字要显示吗?

Possibilities that come to mind:

  • The text color isn't the same as your drawable is it?
  • there is text to display?
盗梦空间 2024-09-22 11:30:50

我发现了问题:我的 ninepatch png 被搞乱了。

I have found the problem : my ninepatch png was messed up.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文