如何在列表视图高级列表项 [英] how to have advanced list item in listview
问题描述
我要得到我的列表项目如下 -
我有与它们相关%值的项目的列表。这样的布局看起来非常有吸引力。谁能告诉我怎样才能做到这一点?
这里的code我曾尝试 -
< XML版本=1.0编码=UTF-8&GT?;
< RelativeLayout的
的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =WRAP_CONTENT
机器人:方向=横向
机器人:layout_height =WRAP_CONTENT>
<的LinearLayout
机器人:layout_width =FILL_PARENT
机器人:方向=横向
机器人:后台=#98F5FF
机器人:layout_height =WRAP_CONTENT
>
< / LinearLayout中>
< LinearLayout中的android:layout_width =FILL_PARENT
机器人:方向=横向
机器人:layout_height =WRAP_CONTENT>
< TextView的Android的:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:ID =@ + ID / text1中
机器人:TEXTSIZE =25dip
机器人:文字颜色=#FFFFFF
机器人:文本=这是文本1/>
< / LinearLayout中>
< / RelativeLayout的>
您可以使用相对布局与绿色背景的线性布局,并放置所有的项目,这样的背景不包括他们另一个布局。按照百分比改变你的背景线性布局的宽度。 这是示意你的XML将是什么样子:
< RelativeLayout的>
<的LinearLayout /> //背景
< LinearLayout中的android:背景=@机器人:彩色/透明>
//在视图中的所有其他元素去这里
< / LinearLayout中>
< / RelativeLayout的>
按设置线性布局的高度myLinearLayout.getLayoutParams()高度= X;
I want to get my list items to look like this -
I have a list of items that have % values associated with them. This layout looks really attractive. Can anyone tell me how can this be done?
Here's the code I have tried -
<?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>
You could use a relative layout with a linear layout for the green background and another layout for placing all your items so that the background doesn't cover them. Change the width of your background linear layout according to percents. This is schematically what your xml will look like:
<RelativeLayout>
<LinearLayout /> // for background
<LinearLayout android:background="@android:color/transparent">
//all other elements in your view go here
</LinearLayout>
</RelativeLayout>
Set the height of linear layout by myLinearLayout.getLayoutParams().height = x;
这篇关于如何在列表视图高级列表项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!