安卓:如何使用XML视图中插入一条垂直线与" FILL_PARENT"高度 - 只有与工作固定大小 [英] Android: how to use an xml view to insert a vertical line with "fill_parent" height - Only working with fixed size
问题描述
因此,这里是我的code,其中我必须手动插入,我不想做的。我想我的其他内容的大小,以确定我的ListView项的高度线的高度,我想我的垂直线只需填写从上到下。目前,它只能当我手动设置DP - 如何我FILL_PARENT办呢?当我尝试使用FILL_PARENT,该行甚至不显示(永远)。
我的列表视图项父:
<的RelativeLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:工具=http://schemas.android.com/tools
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:背景=@绘制/ background_repeatable
机器人:paddingBottom会=@扪/ activity_vertical_margin
机器人:paddingLeft =@扪/ activity_horizontal_margin_venue
机器人:paddingRight =@扪/ activity_horizontal_margin_venue
机器人:paddingTop =5DP
工具:上下文=。CategoriesActivity>
< ListView控件
机器人:ID =@ + ID / categoriesList
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentTop =真
机器人:分=@机器人:彩色/透明
机器人:dividerHeight =@扪/ my_padding
机器人:drawSelectorOnTop =假
机器人:listSelector =@绘制/ list_view_item_background_on_click
机器人:文字=@色/白
机器人:textAlignment =中心
机器人:知名度=看得见>
< /&的ListView GT;
< / RelativeLayout的>
实际列表视图元素视图:
<?XML版本=1.0编码=UTF-8&GT?;
<的RelativeLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_weight =1
机器人:背景=@绘制/ list_view_item_background
机器人:重力=center_vertical
机器人:paddingBottom会=3DP
机器人:paddingLeft =3.5dp
机器人:paddingRight =@扪/ listview_item_left_right_padding
机器人:paddingTop =3DP>
<查看
机器人:ID =@ + ID / vertical_line
机器人:layout_width =3dip
机器人:layout_height =65dp**我想这是FILL_PARENT **
机器人:layout_alignParentLeft =真
机器人:layout_marginRight =5DP
机器人:背景=@色/ SkyBlue2/>
<的TextView
机器人:ID =@ + ID /名称
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentTop =真
机器人:paddingTop =@扪/ listview_item_top_bottom_padding
机器人:layout_toRightOf =@ + ID / vertical_line
机器人:文字颜色=@色/白
机器人:文字=酒吧和烧烤
机器人:TEXTSIZE =@扪/ titleTextSize
机器人:文字样式=大胆/>
<的TextView
机器人:ID =@ + ID / venue_count
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_below =@ + ID /名称
机器人:paddingBottom会=@扪/ listview_item_top_bottom_padding
机器人:layout_toRightOf =@ + ID / vertical_line
机器人:文字颜色=@色/白
机器人:文字=20
机器人:paddingLeft =5DP
机器人:TEXTSIZE =@扪/ subtitleTextSize/>
<的TextView
机器人:ID =@ + ID / venue_text
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_below =@ + ID /名称
机器人:layout_toRightOf =@ + ID / venue_count
机器人:paddingBottom会=@扪/ listview_item_top_bottom_padding
机器人:文字颜色=@色/白
机器人:文字=位置。
机器人:paddingLeft =3DP
机器人:TEXTSIZE =@扪/ subtitleTextSize/>
< ImageView的
机器人:ID =@ + ID / clickIcon
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentRight =真
机器人:layout_centerVertical =真
机器人:adjustViewBounds =真
机器人:SRC =@绘制/ ic_action_next_item/>
< / RelativeLayout的>
它不是完美的解决方案,但黑客的点点。使用RelativeLayout的,里面放1视图上面列表视图行项目的榜首位置布局,同样的方式换一种视图行项目的最后一个视图下方,然后绘制如下1视图及以上填充母身高和神奇的第二视图垂直线有用。不要忘了使用那些2顶部和底部的看法透明色。
So here is my code where I have to manually insert the height of the line which I do NOT want to do.. I want my other content size to determine the height of my listview item and I want my vertical line to simply fill top to bottom. Currently it only works when I set the dp manually - How can I do it with fill_parent ? When I try to use fill_parent, the line does not even show (ever).
parent of my listview items:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background_repeatable"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin_venue"
android:paddingRight="@dimen/activity_horizontal_margin_venue"
android:paddingTop="5dp"
tools:context=".CategoriesActivity" >
<ListView
android:id="@+id/categoriesList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:divider="@android:color/transparent"
android:dividerHeight="@dimen/my_padding"
android:drawSelectorOnTop="false"
android:listSelector="@drawable/list_view_item_background_on_click"
android:text="@color/White"
android:textAlignment="center"
android:visibility="visible" >
</ListView>
</RelativeLayout>
actual listview element view:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/list_view_item_background"
android:gravity="center_vertical"
android:paddingBottom="3dp"
android:paddingLeft="3.5dp"
android:paddingRight="@dimen/listview_item_left_right_padding"
android:paddingTop="3dp" >
<View
android:id="@+id/vertical_line"
android:layout_width="3dip"
android:layout_height="65dp" **I want this to be fill_parent**
android:layout_alignParentLeft="true"
android:layout_marginRight="5dp"
android:background="@color/SkyBlue2" />
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:paddingTop="@dimen/listview_item_top_bottom_padding"
android:layout_toRightOf="@+id/vertical_line"
android:textColor="@color/White"
android:text="Bars and Grills"
android:textSize="@dimen/titleTextSize"
android:textStyle="bold"/>
<TextView
android:id="@+id/venue_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/name"
android:paddingBottom="@dimen/listview_item_top_bottom_padding"
android:layout_toRightOf="@+id/vertical_line"
android:textColor="@color/White"
android:text="20"
android:paddingLeft="5dp"
android:textSize="@dimen/subtitleTextSize"/>
<TextView
android:id="@+id/venue_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/name"
android:layout_toRightOf="@+id/venue_count"
android:paddingBottom="@dimen/listview_item_top_bottom_padding"
android:textColor="@color/White"
android:text="locations"
android:paddingLeft="3dp"
android:textSize="@dimen/subtitleTextSize"/>
<ImageView
android:id="@+id/clickIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:adjustViewBounds="true"
android:src="@drawable/ic_action_next_item" />
</RelativeLayout>
Its not perfect solution, but little bit of hack. use relativelayout, inside it put 1st view above your top position layout of list view row item, same way put another view below your last view of row item, and then draw vertical line below 1st view and above 2nd view with fill parent height and magically it works. Don't forget to use transparent color of those 2 top and bottom views.
这篇关于安卓:如何使用XML视图中插入一条垂直线与&QUOT; FILL_PARENT&QUOT;高度 - 只有与工作固定大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!