2015-02-23 40 views
2
<?xml version="1.0" encoding="utf-8"?> 
<shape 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:visible="true" 
    android:shape="line"> 

<stroke 
     android:width="1dp" 
     android:color="#008000" 
     android:dashWidth="2dp" 
     android:dashGap="2dp"/> 


</shape> 

#horizo​​ntal_line.xml垂直线不垂直扩张[机器人形状]

<?xml version="1.0" encoding="utf-8"?> 
<rotate 
    android:fromDegrees="90" 
    android:toDegrees="90" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:drawable="@drawable/horizontal_line" 
    > 

</rotate> 

#above是垂直线XML

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:orientation="vertical" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="@color/dark_red_color"> 


<View 
     android:layout_width="50dp" 
     android:layout_height="310dp" 
     android:background="@drawable/vertical_line" 
     > 

</View> 
</LinearLayout> 

我试图用垂直线的以上布局或视图。但垂直线不完全展开到其高度。

回答

1

相反的shape你可以使用这个

<View 
android:layout_width="1dp" 
android:layout_height="fill_parent" 
android:background="#FF0000FF" 
android:rotation="90" 
android:background="@android:color/darker_gray"/> 

或者,如果你想与Shape,而不是使用line使用,您可以使用rectangle这样的:

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
android:shape="rectangle" > 
<stroke android:width="1dp" android:color="@color/red"/> 
<size android:width="2dp" android:height="290dp" /> 
</shape> 

编辑

你必须替换这个旧的形状,一个d我认为它会工作:)

<?xml version="1.0" encoding="utf-8"?> 
    <shape xmlns:android="http://schemas.android.com/apk/res/android" 
      android:shape="rectangle"> 
    <stroke 
     android:width="1dp" 
     android:dashWidth="10px" 
     android:dashGap="10px" 
     android:rotation="90" 
     /> 
    </shape> 
+0

我想要的虚线......传播vertically.With简单的颜色作为背景/绘制它可以achieved.But它不会产生虚线。 – jily 2015-02-26 10:23:56

+0

@jily查看我的编辑:) – 2015-02-26 11:12:32

+0

通过缩小矩形的宽度...矩形的左右线重叠,所以没有实现完美的垂直虚线。 – jily 2015-02-26 15:01:19