Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.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 如何在listview中具有高级列表项_Android_Listview - Fatal编程技术网

Android 如何在listview中具有高级列表项

Android 如何在listview中具有高级列表项,android,listview,Android,Listview,我想让我的列表项看起来像这样- 我有一个项目列表,其中有%的值与之关联。这个布局看起来很吸引人。谁能告诉我怎么做 这是我试过的代码- <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:orientat

我想让我的列表项看起来像这样-

我有一个项目列表,其中有%的值与之关联。这个布局看起来很吸引人。谁能告诉我怎么做

这是我试过的代码-

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

<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="wrap_content"
  android:orientation="horizontal"
  android:layout_height="wrap_content">

   <LinearLayout
  android:layout_width="fill_parent"
  android:orientation="horizontal"
  android:background="#98F5FF"
  android:layout_height="wrap_content"
  >
  </LinearLayout>

  <LinearLayout android:layout_width="fill_parent"
  android:orientation="horizontal"
  android:layout_height="wrap_content">
  <TextView android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:id="@+id/text1"
  android:textSize="25dip"
  android:textColor="#FFFFFF"
  android:text="This is text1"/> 
  </LinearLayout>

</RelativeLayout>


您需要使用自定义列表适配器。这将对您有所帮助。

您需要使用自定义列表适配器。这将对您有所帮助。

您可以使用相对布局,绿色背景使用线性布局,而放置所有项目时使用另一个布局,以便背景不会覆盖它们。根据百分比更改背景线性布局的宽度。 这是xml的示意图:

<RelativeLayout>

    <LinearLayout /> // for background

    <LinearLayout android:background="@android:color/transparent">
        //all other elements in your view go here
    </LinearLayout>

</RelativeLayout>

//作为背景
//视图中的所有其他元素都位于此处

通过myLinearLayout.getLayoutParams()设置线性布局的高度。高度=x

您可以使用一个相对布局,绿色背景为线性布局,另一个布局用于放置所有项目,以便背景不会覆盖它们。根据百分比更改背景线性布局的宽度。 这是xml的示意图:

<RelativeLayout>

    <LinearLayout /> // for background

    <LinearLayout android:background="@android:color/transparent">
        //all other elements in your view go here
    </LinearLayout>

</RelativeLayout>

//作为背景
//视图中的所有其他元素都位于此处

通过myLinearLayout.getLayoutParams()设置线性布局的高度。高度=x

我有点困惑。你能确切地告诉我如何使用相对布局吗?另外,如何从代码中更改线性布局的宽度?我仍然无法获得所需的布局。已经用代码更新了问题。请帮助。RelativeLayout不需要定向,请将其删除。同时添加background=“grey\u color”。其余的看起来都不错。如果您还有问题,请告诉我。它只是在列表中显示列表项。任何地方都没有背景色!让我们看看我有点困惑。你能确切地告诉我如何使用相对布局吗?另外,如何从代码中更改线性布局的宽度?我仍然无法获得所需的布局。已经用代码更新了问题。请帮助。RelativeLayout不需要定向,请将其删除。同时添加background=“grey\u color”。其余的看起来都不错。如果您还有问题,请告诉我。它只是在列表中显示列表项。任何地方都没有背景色!让我们