图片视图未显示在Android标签上方

时间:2015-08-05 09:39:08

标签: 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_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>

3 个答案:

答案 0 :(得分:1)

添加

setContentView(R.layout.activity_payment)

解决了这个问题。

答案 1 :(得分:0)

我认为问题出在你的自定义背景中,如果你证明没有背景? 或者你必须改变你的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);

  }

答案 2 :(得分:0)

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

相关问题