Now I need to implement a function just like the html tag , see the pic below:
Firstly, I set the drawableLeft
, and it show like this:
It's not my suppose do. After that I create a class 'LiTextView' implements TextView
, and override the onDraw()
method like this:
@Override
protected void onDraw(Canvas canvas) {
Drawable[] drawables = getCompoundDrawables();
if (drawables != null) {
Drawable drawableLeft = drawables[0];
if (drawableLeft != null) {
canvas.save();
canvas.translate(10, 50);
drawableLeft.draw(canvas);
canvas.restore();
}
}
super.onDraw(canvas);
}
the xml file like this:
<me.naiyu.android.textviewlidemo.widget.LiTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:drawableLeft="@drawable/circle_dot"
android:drawablePadding="10dp"
android:textColor="#000000"
android:textSize="18sp"
android:text="Displays text to the user and optionally allows them to edit it. A TextView is a complete text editor, however the basic class is configured to not allow editing"/>
and it became this(have two circle):
How can I implement the picture one, I now have no idear!