Android 设置背景图像会干扰选项卡活动中的布局

Android 设置背景图像会干扰选项卡活动中的布局,android,tabs,styles,background-image,Android,Tabs,Styles,Background Image,我正在进行一项包含选项卡的活动。当我不使用应用程序背景作为带有以下代码的图像时,布局工作正常 <style name="AppTheme" parent="AppBaseTheme"> <!-- <item name="android:background">@drawable/imagese4copy</item> All customizations t

我正在进行一项包含选项卡的活动。当我不使用应用程序背景作为带有以下代码的图像时,布局工作正常

   <style name="AppTheme" parent="AppBaseTheme">
      <!--  <item name="android:background">@drawable/imagese4copy</item>
         All customizations that are NOT specific to a particular API-level can go here. -->
    </style>
activity\u main\u activity.xml

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </LinearLayout>
</TabHost>
请告诉我当我包含背景图像时出现了什么问题,以及如何纠正它

关于,
Sourabh

在中进行研究后,我发现如果在应用程序中应用背景图像,它将为应用程序中的所有视图设置背景。由于Tab和TextView是一个视图,它们也有背景图像,因此会干扰布局

我不知道是否有更完美的解决方案可用,但将背景图像设置为LinearLayout或RelativeLayout将解决问题,但您必须在每个xml文件上应用此选项,以便在所有活动中获得相同的背景

例如:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background_darkgreyrough"
    tools:context=".Overview" >

在中进行研究后,我发现,若在应用程序中应用背景图像,则会将背景设置为应用程序中的所有视图。由于Tab和TextView是一个视图,它们也有背景图像,因此会干扰布局

我不知道是否有更完美的解决方案可用,但将背景图像设置为LinearLayout或RelativeLayout将解决问题,但您必须在每个xml文件上应用此选项,以便在所有活动中获得相同的背景

例如:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background_darkgreyrough"
    tools:context=".Overview" >


当您设置背景时,代码会发生什么变化?当我刚刚添加
@drawable/imagese4copy
和不需要的布局comesok时,但是您在清单文件中的哪里设置了样式。事实上,我想在所有活动中应用这个主题。如果你尝试设置这个主题,会发生什么,有另一个主题,但里面没有注释?:@drawable/imagese4copy注意这不是一个答案,但我需要显示代码…以及在设置背景时代码发生了什么变化?当我只添加
@drawable/imagese4copy
和不需要的布局comesok时,但是在清单文件中,您在哪里设置了样式。实际上,我希望在所有活动中都应用此主题。如果您尝试设置此主题(使用另一个主题,但没有内部注释),会发生什么情况?:@drawable/imagese4copy注意这不是答案,但我需要显示代码。。。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background_darkgreyrough"
    tools:context=".Overview" >