Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/207.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android RelativeLayout中的listview不可见,下面是如何在相对布局中放置列表视图的代码_Android_Android Listview_Android Relativelayout - Fatal编程技术网

Android RelativeLayout中的listview不可见,下面是如何在相对布局中放置列表视图的代码

Android RelativeLayout中的listview不可见,下面是如何在相对布局中放置列表视图的代码,android,android-listview,android-relativelayout,Android,Android Listview,Android Relativelayout,RelativeLayout中的列表视图不可见,如何将listview放置在RelativeLayout中?下面是代码 这是设置屏幕.xml 它只包含xml代码。代码部分解释得很仔细,请放心。这是我第一次发布这段代码,上面写着PostComeConnText <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android

RelativeLayout
中的列表视图不可见,如何将
listview
放置在
RelativeLayout
中?下面是代码

这是设置屏幕.xml

它只包含xml代码。代码部分解释得很仔细,请放心。这是我第一次发布这段代码,上面写着PostComeConnText

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:background="@drawable/black_background_metal"
 android:orientation="vertical" >
   <!-- this is a image with a text. if this can be relative layout -->
    <LinearLayout
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginTop="50dip" >

           <ImageView
             android:id="@+id/imageView1"
             android:layout_width="40dp"
             android:layout_height="40dp"
             android:layout_alignParentLeft="true"
             android:scaleType="fitXY"
             android:src="@drawable/settings1" />

           <TextView
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_gravity="left"
             android:layout_marginTop="60dip"
             android:paddingTop="10dip"
             android:text="@string/settings_label"
             android:textSize="16sp" />
     </LinearLayout>
              <!--  here if i put relativelaout listview becomes invisible-->
     <ListView
        android:id="@+id/list"
        android:layout_width="match_parent" 
        android:layout_height="0dip"
        android:layout_gravity="center_vertical"
        android:layout_weight="0.91"
        android:textColor="@android:color/white" >
        </ListView>

  </LinearLayout>


android:layout\u height=“0dip”
android:layout\u weight=“0.91”
不适用于
RelativeLayout
。您将需要使用下面的
android:layout\u
android:layout\u alignParentBottom
相对布局将不支持
android:layout\u height=“0dip”
android:layou weight=“0.91”
。下面是使用relativelayout修改的xml

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<!-- this is a image with a text. if this can be relative layout -->
<LinearLayout
    android:layout_width="wrap_content"
    android:id="@+id/linear"
    android:layout_height="wrap_content"
    android:layout_marginTop="50dip" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:layout_alignParentLeft="true"
        android:scaleType="fitXY"
        android:src="@drawable/ic_launcher" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="left"
        android:layout_marginTop="60dip"
        android:paddingTop="10dip"
        android:text="@string/action_settings"
        android:textSize="16sp" />
</LinearLayout>
<!--  here if i put relativelaout listview becomes invisible-->
<ListView
    android:id="@+id/list"
    android:layout_width="match_parent"
    android:layout_gravity="center_vertical"
    android:layout_below="@id/linear"
    android:textColor="@android:color/white"
    android:layout_height="match_parent">
</ListView>


能否发布活动的代码,listview是否仅在运行时不可见?请参考这将对您有所帮助: