背景图像导致第二线性布局消失



我有一个像这样的布局

<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical"
  style="@style/Splash">
  <TextView android:id="@+id/splash_title" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        style="@style/Splash.H1"
        android:text="@string/splash_title"/>
  <LinearLayout android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="horizontal">
    <ImageView 
        android:id="@+id/splash_image"
        android:src="@drawable/ic_launcher_ftnicon"
        style="@style/Splash.Image"/>
    <TextView android:id="@+id/splash_powered_by" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        style="@style/Splash.H2"
        android:text="@string/splash_powered_by"/>
</LinearLayout>
</LinearLayout>

我的风格是这样的

<style name="Splash">
    <item name="android:gravity">center</item>
    <item name="android:background">#FFFFFF</item>
</style>

当我将背景改为可绘制时,如下所示:

<style name="Splash">
    <item name="android:gravity">center</item>
    <item name="android:background">@drawable/bg_splash</item>
</style>

第二个线性布局完全消失。显示背景图像,显示标题的文本视图。

我认为是这样的

你的@drawable/bg_splash是一个全屏图像。

请记住,对于样式,所有的子样式都将继承父样式的设置。飞溅。H1的背景也将与Splash相同。这意味着所有视图的背景将被设置为相同的全屏图像。使用您定义的布局方式,将显示的唯一视图是"@+id/splash_title"文本视图。

最新更新