Android 与下面的ListView相对透明
我有一个透明背景的相对布局。以及下面带有列表视图的线性布局。问题是,我在transaprent RelativeLayout下面看不到我的列表视图。以下是我的xml:Android 与下面的ListView相对透明,android,Android,我有一个透明背景的相对布局。以及下面带有列表视图的线性布局。问题是,我在transaprent RelativeLayout下面看不到我的列表视图。以下是我的xml: <RelativeLayout android:id="@+id/layoutabove" android:background="#55000000" android:layout_width="match_parent" android:layout_hei
<RelativeLayout
android:id="@+id/layoutabove"
android:background="#55000000"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="@+id/loginbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Login" />
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/myimage" />
</RelativeLayout>
<LinearLayout
android:id="@+id/mainlayout"
android:layout_width="fill_parent"
android:background="#000000"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="fill_parent" >
</ListView>
</LinearLayout>
只是黑色背景。请按以下方式尝试:
你可以说得更清楚,对吧?请添加图像,它现在看起来怎么样?您试图实现什么?您已在Listview/LinearLayoutPost的背景中添加了黑色,以便我们可以查看RelativeLayout和LinearLayoutPost的父视图。可能是因为您已将高度匹配\u parent指定给RelativeLayout。您的布局显示您已添加了两个根布局在xml中,这是不可能的。应该只有一个根布局,并在该根布局中插入其他布局和视图。或者您只发布了布局的一半代码
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layoutabove"
android:layout_width="match_parent"
android:layout_height="match_parent"
<RelativeLayout
android:id="@+id/layoutabove"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#55000000" >
<Button
android:id="@+id/loginbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Login" />
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/myimage" />
</RelativeLayout>
<LinearLayout
android:id="@+id/mainlayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#000000"
android:orientation="vertical"
android:layout_below="@+id/layoutabove" >
<ListView
android:id="@+id/listView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
</RelativeLayout>