Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/231.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:在列表项的ImageView后面画线_Android_Android Listview_Imageview - Fatal编程技术网

Android:在列表项的ImageView后面画线

Android:在列表项的ImageView后面画线,android,android-listview,imageview,Android,Android Listview,Imageview,我想在列表项中的ImageView后面画一条线,它填充列表项的整个高度。下面链接中的图像显示了我想要的结果。蓝线就是我想要的 我有一个ListView,每行有一个自定义适配器和布局。该行由一个包含几个元素的相对布局组成:一个固定在左侧的特定大小的图像,一个固定在右侧的特定大小的文本视图,以及一个填充中间其余空间的文本视图 我想在ImageView的顶部和底部显示一条细线,并填充该列表项的剩余空间。如果中间有大量文本,列表项的大小可能会大于图像大小。我怎样才能做到这一点 我尝试了多种方法,其中f

我想在列表项中的ImageView后面画一条线,它填充列表项的整个高度。下面链接中的图像显示了我想要的结果。蓝线就是我想要的

我有一个ListView,每行有一个自定义适配器和布局。该行由一个包含几个元素的相对布局组成:一个固定在左侧的特定大小的图像,一个固定在右侧的特定大小的文本视图,以及一个填充中间其余空间的文本视图

我想在ImageView的顶部和底部显示一条细线,并填充该列表项的剩余空间。如果中间有大量文本,列表项的大小可能会大于图像大小。我怎样才能做到这一点

我尝试了多种方法,其中framelayout的视图与父视图和ImageView匹配/填充,linearlayout的视图有3个(顶行、ImageView、填充父视图的底行),图像在IDE渲染中看起来正确,但这些行不会一直延伸,甚至在应用程序实际运行时也不会显示出来

这是我在imageview后面没有线条的布局

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

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:padding="@dimen/marginTop"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
  <!--Line should be "behind" (extending from top and bottom) of this imageView and should extend to the full height of the RelativeLayout after it has been rendered-->
  <ImageView
          android:id="@+id/tabIcon"
          android:src="@drawable/face"
          android:layout_marginTop="@dimen/margin"
          android:layout_width="@dimen/catchSize"
          android:layout_height="@dimen/catchSize"/>
  <TextView
          android:id="@+id/tabUpdateTime"
          android:layout_marginLeft="@dimen/margin"
          android:layout_alignParentRight="true"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"/>
  <TextView
          android:id="@+id/tabText"
          android:text="@string/long_string"
          android:layout_marginLeft="@dimen/margin"
          android:layout_marginRight="@dimen/margin"
          android:layout_toRightOf="@id/tabIcon"
          android:layout_toLeftOf="@id/tabUpdateTime"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"/>

</RelativeLayout>

您只需为图像和垂直线创建单独的布局,要绘制垂直线,您需要添加宽度为1dp或厚度为所需的视图

请尝试使用以下代码:

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

    <!-- Line should be "behind" (extending from top and bottom) of this imageView and should extend to the full height of the RelativeLayout after it has been rendered -->

    <RelativeLayout
        android:id="@+id/image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/tabText" >

        <View
            android:id="@+id/verticleLine"
            android:layout_width="1dp"
            android:layout_height="match_parent"
            android:layout_centerInParent="true"
            android:background="#0000ff" />

        <ImageView
            android:id="@+id/tabIcon"
            android:layout_width="@dimen/catchSize"
            android:layout_height="@dimen/catchSize"
            android:layout_centerInParent="true"
            android:layout_marginTop="@dimen/margin"
            android:src="@drawable/face" />
    </RelativeLayout>

    <TextView
        android:id="@+id/tabUpdateTime"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_marginLeft="@dimen/margin" />

    <TextView
        android:id="@+id/tabText"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/margin"
        android:layout_marginRight="@dimen/margin"
        android:layout_toLeftOf="@id/tabUpdateTime"
        android:layout_toRightOf="@id/image"
        android:text="@string/long_string" />

</RelativeLayout>

因此,我设法通过使用封闭的线性布局来解决这个问题。我已经改变了一些保证金的内容,但我得到了我想要的效果。:)



你能展示一些你想要的用户界面或图像吗?不幸的是,我没有10个声誉,所以我不能上传图像。真蠢!愚蠢,所以你在愚蠢的事情上寻求帮助。如果你有足够的知识,你可以上传图片到其他地方,并可以在这里传递链接。我已经链接了我想要的图片。不幸的是,这不起作用。图像被缩小了很多,所有的文本都被聚在一起。然而,这条线确实穿过了图像。为此,你需要根据屏幕分辨率和填充来确定大小。
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="horizontal"
              android:paddingLeft="@dimen/marginTop"
              android:paddingRight="@dimen/marginTop"
              android:layout_width="match_parent"
              android:layout_height="match_parent">
  <!--Line should be "behind" (extending from top and bottom) of this imageView and should extend to the full height of the RelativeLayout after it has been rendered-->
  <LinearLayout
          android:orientation="vertical"
          android:clipChildren="false"
          android:id="@+id/frameTabIcon"
          android:layout_marginRight="@dimen/margin"
          android:layout_width="wrap_content"
          android:layout_height="match_parent">
    <View
            android:id="@+id/tabTopLine"
            android:layout_width="@dimen/lineThickNess"
            android:layout_height="@dimen/marginTop"
            android:background="@android:color/black"
            android:layout_gravity="center_horizontal"/>
    <ImageView
            android:onClick="deletePersonOnClick"
            android:id="@+id/tabIcon"
            android:src="@drawable/face"
            android:layout_width="@dimen/catchSize"
            android:layout_height="@dimen/catchSize"/>

    <View
          android:id="@+id/tabBottomLine"
          android:background="@android:color/black"
          android:layout_gravity="center_horizontal"
          android:minHeight="@dimen/marginTop"
          android:layout_width="@dimen/lineThickNess"
          android:layout_height="match_parent"/>

  </LinearLayout>

  <RelativeLayout
          android:layout_marginTop="@dimen/marginTop"
          android:layout_marginBottom="@dimen/marginTop"
          android:layout_width="match_parent"
          android:layout_height="match_parent">

    <TextView
            android:id="@+id/tabUpdateTime"
            android:layout_marginLeft="@dimen/margin"
            android:layout_alignParentRight="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
    <TextView
            android:id="@+id/tabText"
            android:text="@string/long_string"
            android:layout_marginLeft="@dimen/margin"
            android:layout_marginRight="@dimen/margin"
            android:layout_toLeftOf="@id/tabUpdateTime"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>
  </RelativeLayout>
</LinearLayout>