maybe you try this , in you custonm view xml :

<net.pocketmagic.customangletext.CustomTextView.view
        android:id="@+id/yourID"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
         /> 



在 2012年3月6日星期二UTC+8下午5时07分28秒,chowdary nani写道:
>
> Hi All,
>
>  i am working  with custom views using in xml layouts
> Following is my custom view code:
>
> public class CustomTextView extends View {
>
>     private int m_nColor;
>     private Typeface m_tTypeface;
>     private int m_nSize;
>     private int m_nRotationAngle, m_nRotationW, m_nRotationH;
>     private String m_szText;
>
>     public CustomTextView(Context context) {
>         super(context);
>         // set default parameters
>         Log.d("dghgfhf", "dfghgfh");
>         m_nColor = Color.WHITE;
>         m_nSize = 14;
>         m_nRotationAngle = 0;
>         m_nRotationW = 0;
>         m_nRotationH = 0;
>         m_tTypeface = Typeface.create("arial", Typeface.NORMAL);
>     }
>
>     public CustomTextView(Context context, AttributeSet attrs) {
>         super(context, attrs);
>     }
>     public void SetColor(int newcolor) {
>         m_nColor = newcolor;
>         this.invalidate();
>     }
>
>     public void SetTextSize(int newsize) {
>         m_nSize = newsize;
>         this.invalidate();
>     }
>
>     // style: normal-0,bold-1,italic-2,bold-italic-3,
>     public void SetFont(String newfontface, int style) {
>         m_tTypeface = Typeface.create(newfontface, style);
>         this.invalidate();
>     }
>
>     public void SetRotation(int newangle, int neww, int newh) {
>         m_nRotationAngle = newangle;
>         m_nRotationW = neww;
>         m_nRotationH = newh;
>         this.invalidate();
>     }
>
>     public void SetText(String newtext) {
>         m_szText = newtext;
>         this.invalidate();
>     }
>
>     @Override
>     protected void onDraw(Canvas canvas) {
>         super.onDraw(canvas);
>         Paint paint = new Paint();
>         paint.setTypeface(m_tTypeface);
>         paint.setStyle(Paint.Style.FILL);
>         paint.setColor(m_nColor);
>         // paint.setShadowLayer(1, 0, 1, Color.parseColor("#000000"));
>         paint.setTextSize(m_nSize);
>         canvas.rotate(m_nRotationAngle, m_nRotationW, m_nRotationH);
>         canvas.drawText(m_szText, 0, 0, paint);
>
>     }
> }
>
> Following is my layout:
> <?xml version="1.0" encoding="utf-8"?>
> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android";
>     xmlns:GUI="
> http://schemas.android.com/apk/res/net.pocketmagic.customangletext";
>     android:layout_width="fill_parent"
>     android:layout_height="fill_parent"
>     android:orientation="vertical" >
>
>     <view
>         android:id="@+id/yourID"
>         android:layout_width="wrap_content"
>         android:layout_height="wrap_content"
>         android:layout_margin="10dp"
>         class="net.pocketmagic.customangletext.CustomTextView" />
>
> </LinearLayout>
>
>
> i am  getting null pointer exception i am unable find where i am going 
> wrong please help me
>
>
> Thanks
> Naveen.
>

在 2012年3月6日星期二UTC+8下午5时07分28秒,chowdary nani写道:
>
> Hi All,
>
>  i am working  with custom views using in xml layouts
> Following is my custom view code:
>
> public class CustomTextView extends View {
>
>     private int m_nColor;
>     private Typeface m_tTypeface;
>     private int m_nSize;
>     private int m_nRotationAngle, m_nRotationW, m_nRotationH;
>     private String m_szText;
>
>     public CustomTextView(Context context) {
>         super(context);
>         // set default parameters
>         Log.d("dghgfhf", "dfghgfh");
>         m_nColor = Color.WHITE;
>         m_nSize = 14;
>         m_nRotationAngle = 0;
>         m_nRotationW = 0;
>         m_nRotationH = 0;
>         m_tTypeface = Typeface.create("arial", Typeface.NORMAL);
>     }
>
>     public CustomTextView(Context context, AttributeSet attrs) {
>         super(context, attrs);
>     }
>     public void SetColor(int newcolor) {
>         m_nColor = newcolor;
>         this.invalidate();
>     }
>
>     public void SetTextSize(int newsize) {
>         m_nSize = newsize;
>         this.invalidate();
>     }
>
>     // style: normal-0,bold-1,italic-2,bold-italic-3,
>     public void SetFont(String newfontface, int style) {
>         m_tTypeface = Typeface.create(newfontface, style);
>         this.invalidate();
>     }
>
>     public void SetRotation(int newangle, int neww, int newh) {
>         m_nRotationAngle = newangle;
>         m_nRotationW = neww;
>         m_nRotationH = newh;
>         this.invalidate();
>     }
>
>     public void SetText(String newtext) {
>         m_szText = newtext;
>         this.invalidate();
>     }
>
>     @Override
>     protected void onDraw(Canvas canvas) {
>         super.onDraw(canvas);
>         Paint paint = new Paint();
>         paint.setTypeface(m_tTypeface);
>         paint.setStyle(Paint.Style.FILL);
>         paint.setColor(m_nColor);
>         // paint.setShadowLayer(1, 0, 1, Color.parseColor("#000000"));
>         paint.setTextSize(m_nSize);
>         canvas.rotate(m_nRotationAngle, m_nRotationW, m_nRotationH);
>         canvas.drawText(m_szText, 0, 0, paint);
>
>     }
> }
>
> Following is my layout:
> <?xml version="1.0" encoding="utf-8"?>
> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android";
>     xmlns:GUI="
> http://schemas.android.com/apk/res/net.pocketmagic.customangletext";
>     android:layout_width="fill_parent"
>     android:layout_height="fill_parent"
>     android:orientation="vertical" >
>
>     <view
>         android:id="@+id/yourID"
>         android:layout_width="wrap_content"
>         android:layout_height="wrap_content"
>         android:layout_margin="10dp"
>         class="net.pocketmagic.customangletext.CustomTextView" />
>
> </LinearLayout>
>
>
> i am  getting null pointer exception i am unable find where i am going 
> wrong please help me
>
>
> Thanks
> Naveen.
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to