簡體   English   中英

Android在應用程序上將LinearLayout用作所有其他LinearLayouts的背景

[英]Android using LinearLayout as Background for all others LinearLayouts on the App

我有一個LinearLayout,里面還有其他2個LinearLayouts。 每一個它里面都有一個ImageView。 我需要將此LinearLayout設置為我的應用程序的所有其他LinearLayouts的背景。 我嘗試使用“包含”和“合並”,但是沒有用,因為我需要在“背景LinearLayout”中放入其他LinearLayout,然后嘗試使用“樣式”,但是我不知道如何在其中添加ImageViews LinearLayouts。 有可能的? 最后,現在我正在嘗試使用“ Drawable”,但是我不知道這是否是解決方案。

我需要想法,需要幫助,有人可以幫助我嗎?

這是我的“背景LinearLayout”:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@layout/gradient_background">

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal"
    android:layout_marginTop="170dip"> 

    <ImageView
        android:id="@+id/background_title"
        android:src="@drawable/titulo_fondo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

</LinearLayout>

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="left|bottom"
    android:layout_marginLeft="-54dip"
    android:layout_marginBottom="-24dip"> 

    <ImageView
        android:id="@+id/background_logo"
        android:src="@drawable/circulo_logo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

</LinearLayout> 

</LinearLayout>

謝謝,抱歉我的英語不好

樣式可能是解決方法,請嘗試創建如下樣式:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="MyTheme" parent="@android:style/Theme.Light">
<item name="android:windowBackground">@drawable/my_image</item>
</style>

並使用清單中的theme屬性配置整個應用程序以使用它,例如

<application
   android:icon="@drawable/icon"
   android:label="@string/app_name"
   android:theme="@style/MyTheme"
   ...
</application>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM