我有一个列表项布局,这个布局在StickyListHeaderListView中使用,并在图像后面包含一个垂直分隔符。问题是,尽管视图分隔符绘制在预览屏幕上,但从未在实际设备上绘制。
下面是xml布局代码
<?xml version="1.0" encoding="utf-8"?>
<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:minHeight="80dp"
       android:paddingLeft="@dimen/padding_medium"
       android:paddingRight="@dimen/padding_medium"
       tools:ignore="MissingPrefix">
<TextView
    android:id="@+id/textview_date"
    fontPath="@string/font_semi_bold"
    android:layout_width="wrap_content"
    android:maxWidth="60dp"
    android:layout_height="match_parent"
    android:layout_centerVertical="true"
    android:gravity="center_vertical|right"
    android:textAppearance="@android:style/TextAppearance.Holo.Medium"
    android:textColor="#999999"
    tools:text="21\nFeb" />
<RelativeLayout
    android:id="@+id/container"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_toRightOf="@+id/textview_date"
    android:minWidth="50dp"
    android:paddingLeft="@dimen/padding_extra_small"
    android:paddingRight="@dimen/padding_extra_small">
    <View
        android:layout_width="1px"
        android:layout_height="match_parent"
        android:layout_centerHorizontal="true"
        android:background="#999999" />
    <ImageView
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:layout_alignParentTop="true"
        android:layout_marginTop="@dimen/margin_small"
        android:src="@drawable/test_event_cat_1" />
</RelativeLayout>
<TextView
    android:id="@+id/textview_event_name"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@+id/container"
    android:layout_marginTop="@dimen/margin_small"
    android:textColor="#999999"
    fontPath="@string/font_medium"
    tools:text="ACS Nights’ Soccer Finale"
    android:textAppearance="@android:style/TextAppearance.Holo.Medium" />
<TextView
    android:id="@+id/textview_interval"
    android:layout_width="match_parent"
    android:textAppearance="@android:style/TextAppearance.Holo.Small"
    android:layout_alignLeft="@+id/textview_event_name"
    android:layout_below="@id/textview_event_name"
    android:layout_marginTop="@dimen/margin_small"
    android:textColor="#999999"
    tools:text="4:00 PM - 6:00 PM"
    android:layout_height="wrap_content" />
 </RelativeLayout>此代码在Android Studio的预览窗口中生成正确的布局

但是设备上的输出不像在预览中那样包含任何垂直线

我试着把垂直线放在布局的不同部分,但仍然没有显示在真正的设备上。任何帮助都将不胜感激。
发布于 2015-02-12 08:39:18
如何将新项目添加到listView?
是否每个项目都具有整个xml文件的布局?
那么一行将使用整个layout.xml文件?
编辑:
我猜想,由于您在与线的相对布局中有2个视图,所以图像会将线推出屏幕。我花了一段时间去找一些参考资料,但是here。
RelativeLayout的工作方式相同,相对布局中的最后一个图像获胜。
所以你必须找到一种方法,在线条的顶端绘制图像。或者,您可以绘制一条简单的线条作为可绘制内容,并将其设置为包含该图像的relativeLayout的背景
https://stackoverflow.com/questions/28467209
复制相似问题