Question

I need to draw lines inside listView items, this line must show dependences between items. enter image description here I have read this, but i think it is difficult to draw lines by points in my case.And i think to use proggres bar, but it isn't a nice solution too What is the best practice to make this?for example, if i have tv1.weight=1, customview weight=3, tv.weight=1 how can i set widht of line?

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

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

<TextView
        android:layout_width="wrap_content"
        android:layout_height="2dp"
        android:text="New Text"
        android:id="@+id/textView"/>

<View
        android:layout_width="50dp"
        android:layout_height="1dp"
        android:background="@android:color/holo_blue_light" />

<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="New Text"
        android:id="@+id/textView"/>

Was it helpful?

Solution

First you need to make a custom adapter for Listview.

Then, for drawing line use :

<View
     android:layout_width="fill_parent"
     android:layout_height="2dp"
     android:background="#c0c0c0"/>

Now since the width of line is dependent on number inside listview item, you could easily set the layout_width of line inside getView() method of custom adapter.

You can set the height and width of a view in a LinearLayout like this

View someView = (View).findViewById(someId):
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) 
          someView .getLayoutParams();
params.height = 130;
someView .setLayoutParams(params);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top