Lin Yu Cheng
Lin Yu Cheng

Reputation: 667

Android how to draw a shape defined in xml on canvas

I defined a dotted line in the xml:

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

I load it as a drawable and try to draw it under each line of EditText:

Rect r = mRect;
int baseline = getLineBounds( line , r);
drawable.setBounds(r.left, baseline + 1, r.right, baseline + 2);
divider.draw(canvas);

However, it only show a solid line, not a dotted one. what is the problem ??

Upvotes: 2

Views: 1730

Answers (1)

Lin Yu Cheng
Lin Yu Cheng

Reputation: 667

finally, I found that it is effected by hard acceleration. so just close it and everything will be fine.

Upvotes: 1

Related Questions