Background image causes second linear layout to vanish
I have a layout that looks like this
<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>
My style looks like this
<style name="Splash">
<item name="android:gravity">center</item>
<item name="android:background">#FFFFFF</item>
</style>
when I change the background to a drawable, like this:
<style name="Splash">
<item name="android:gravity">center</item>
<item name="android:background">@drawable/bg_splash</item>
</style>
The second linear layout vanishes completely. The background image shows and the text view for the title shows.
Here is what I think is happening.
Your @drawable/bg_splash is a full screen image.
Remember that with styles, all children will inherit the settings of the parent (ie. Splash.H1 will also have the same background as Splash). This means that the background of all of the views will be set to the same full screen image. With the layout the way you have it defined, the only view that will show is the "@+id/splash_title" text view. The linear layout will be forced off screen to the bottom.
精彩评论