У меня есть собственный TabHost, который добавляет такие вкладки
private void setTab(View view, String tag, Intent intent)
{
View tabView = LayoutInflater.from(context).inflate(R.layout.tabs_bg, null);
TextView tv = (TextView) view.findViewById(R.id.tabsText);
tv.setText(tag);
TabSpec setContent = mTabHost.newTabSpec(tag).setIndicator(tabView)
.setContent(intent);
mTabHost.addTab(setContent);
}
где mTabHost — хост вкладки, а tabs_bg.xml просто имеет текстовое представление в линейном макете. (Мой основной макет такой же, как Пример макета вкладки; я просто пытаюсь использовать небольшие текстовые вкладки.) Моя информационная вкладка вызывается следующим образом:
intent = new Intent().setClass(this, AboutScreen.class);
setTab(new TextView(this), "about", intent);
AboutScreen расширяет Activity, и все, что он делает, это устанавливает ContentView для этого
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<TextView android:id="@+id/AboutUsTitle"
android:textColor="#ffffffff" android:text="@string/about_title"
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:layout_gravity="center" android:gravity="center"
android:background="@drawable/about_title"/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="15dip">
<TextView android:id="@+id/AboutContents"
android:text="@string/about_contents" android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
</LinearLayout>
</LinearLayout>
где @drawable/about_title это:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#ffffffff"
android:endColor="#ff333333"
android:angle="90"/>
</shape>
Этот рисунок не отображается внутри FrameLayout. Все остальное отображается корректно. Любые идеи, что я делаю неправильно?
EDIT: если я установлю это программно
TextView tvAboutUsTitle = (TextView) findViewById(R.id.AboutUsTitle);
tvAboutUsTitle.setBackgroundResource(R.drawable.about_title);
он появляется. Почему это отличается от установки в xml?