【问题标题】:Android using LinearLayout as Background for all others LinearLayouts on the AppAndroid 使用 LinearLayout 作为应用程序上所有其他 LinearLayouts 的背景
【发布时间】:2012-06-11 19:16:25
【问题描述】:

我有一个 LinearLayout,里面还有另外 2 个 LinearLayout。每一个里面都有一个 ImageView。 我需要将此 LinearLayout 设置为我的应用程序的所有其他 LinearLayouts 的背景。 我尝试使用“包含”和“合并”,但没有成功,因为我需要将其他 LinearLayout 放在我的“背景 LinearLayout”中 然后我尝试了“样式”,但我不知道如何在 LinearLayouts 中添加 ImageViews。有可能的? 最后现在我正在尝试使用“Drawable”,但我不知道这是否是解决方案。

我需要一些想法,一些帮助,有人可以帮助我吗?

这是我的“背景线性布局”:

<?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>

感谢和抱歉我的英语不好

【问题讨论】:

    标签: android styles themes drawable android-linearlayout


    【解决方案1】:

    样式可能是要走的路,尝试创建如下样式:

    <?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>
    

    并配置您的整个应用程序以使用清单中的主题属性,例如

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

    【讨论】:

    • 但我需要在我的布局中添加 2 个 ImageView,每个都有不同的 X、Y 位置。我该怎么做?谢谢
    猜你喜欢
    • 2012-03-19
    • 2017-02-16
    • 1970-01-01
    • 1970-01-01
    • 2013-10-19
    • 1970-01-01
    • 2014-04-03
    • 1970-01-01
    • 2014-05-13
    相关资源
    最近更新 更多