I am trying to implement a custom onDraw()
method in my EditText
.
onDraw
is getting called - I can see the log messages, but it is not drawing anything.
Can anyone please tell me what I am doing wrong?
Here is an excerpt from my layout:
<view xmlns:android="http://schemas.android.com/apk/res/android"
class ="my.package.NotePadEditView"
android:inputType="textMultiLine"
android:id="@+id/edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top"
android:background="@android:color/transparent"
android:singleLine="false"
>
<requestFocus/>
</view>
</ScrollView>
Here is the class (just with some test code for now):
public class NotePadEditView extends EditText {
Paint paint = new Paint();
public NotePadEditView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(3);
paint.setColor(0xFF0000);
}
@Override
protected void onDraw(Canvas canvas) {
Log.d("NotePadEditView", "Calling onDraw()"); // These log messages are displaying
canvas.drawLine(0, 0, 50, 50, paint); // just some random stuff so we know when we are done. (Note: these are not displaying - what's up with that???)
canvas.drawText("Hello, World", 30, 30, paint);
super.onDraw(canvas);
}
// more constructors, etc
No comments:
Post a Comment