图像视图未出现在Android选项卡上方

图像视图未出现在Android选项卡上方,android,imageview,Android,Imageview,我需要在我的标签上方有一个图像视图。但ImageView根本不在设备中出现。在设备中,最上面的选项卡没有图像视图。下面是我的布局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_w

我需要在我的标签上方有一个图像视图。但ImageView根本不在设备中出现。在设备中,最上面的选项卡没有图像视图。下面是我的布局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="wrap_content"
    >
<LinearLayout

    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <ImageView
      android:layout_width="fill_parent"
      android:layout_height="100dp"
      android:id="@+id/imageView2"
      android:background="@color/list_view_blue"
    />

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/imageView2"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_marginTop="100dp" />
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>
    </LinearLayout>
</TabHost>

如果你证明自己没有背景,我认为问题在于你的定制背景? 或者,您必须在onCreateView中进行如下更改:

 public View onCreateView(LayoutInflater inflater, ViewGroup container,

    Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.tab2m, container, false);

    ImageView img1 = (ImageView)rootView.findViewById(R.id.imageView2);

  }
添加

setContentView(R.layout.activity_payment)

修复了该问题。

使用相对布局而不是线性布局

Hi Sundeep,添加setContentView(R.Layout.activity\u payment)修复了该问题