views:

22

answers:

3

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)

A: 

Possibilities that come to mind:

  • The text color isn't the same as your drawable is it?
  • there is text to display?
JRL
Quick answer : no and yes :)Default text color is greyish/white and string exists.If I remove "android:background="@drawable/widget_bg"" then text is display, wich makes me think the text is _behind_ the bg
Choumarin
@Choumarin: try it with a default 9-patch such as `android:drawable/menuitem_background_pressed`.
JRL
compliler error : ressource is not public :/
Choumarin
A: 

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

Choumarin
A: 

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?

Amit
I guess he didn't set a content area while converting it to 9-patch.
Octavian Damiean