2016-09-29 49 views
0

enter image description here圖Line

我有繪畫線問題如上面一峯。我怎樣才能做到這一點?這是視圖的代碼,我需要實現它。我想我需要使用畫布,但我不確定。感謝您的任何建議!

<RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:layout_marginTop="@dimen/linear_layout_buttons_margin_top" 
     android:orientation="vertical"> 

     <TextView 
      android:id="@+id/button_from_city" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="4dp" 
      android:layout_marginLeft="60dp" 
      android:layout_marginRight="60dp" 
      android:layout_marginTop="4dp" 
      android:background="@drawable/button_white" 
      android:drawableLeft="@drawable/ic_green" 
      android:drawablePadding="@dimen/dots_white_button_padding" 
      android:drawableStart="@drawable/ic_green" 
      android:gravity="center_vertical" 
      android:hint="@string/from_place" 
      android:padding="@dimen/dots_white_button_padding" 
      android:textColor="@color/color_accent" 
      android:textColorHint="@color/text_view_hint_color"/> 

     <TextView 
      android:id="@+id/button_to_city" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@id/button_from_city" 
      android:layout_marginBottom="4dp" 
      android:layout_marginLeft="60dp" 
      android:layout_marginRight="60dp" 
      android:layout_marginTop="4dp" 
      android:background="@drawable/button_white" 
      android:drawableLeft="@drawable/ic_red" 
      android:drawablePadding="@dimen/dots_white_button_padding" 
      android:drawableStart="@drawable/ic_red" 
      android:gravity="center_vertical" 
      android:hint="@string/to_place" 
      android:padding="@dimen/dots_white_button_padding" 
      android:textColor="@color/color_accent" 
      android:textColorHint="@color/text_view_hint_color"/> 
    </RelativeLayout> 

回答

1

您可以根據所需工作條件爲文本視圖提供兩個可繪製資源並將它們設置爲drawableStart。這裏的要點是使用包含彩色圓圈和線條的圖像,這比使用畫布繪製佈局要簡單得多。

0

我會簡單地在點繪圖上方和下方添加兩個寬度爲1dp的灰色背景視圖,並根據您的項目位置管理可見性。