How to add Custom View +Relative Layout into ViewGroup

Posted by TimothyMiller on Stack Overflow See other posts from Stack Overflow or by TimothyMiller
Published on 2010-12-23T01:50:21Z Indexed on 2010/12/23 1:54 UTC
Read the original article Hit count: 605

Filed under:
|
|
|
|

Hi I am creating a View where you can draw on the screen, using a view, where I would like to have a button/titlebar drawn at the top of the screen. Here is my current code

public class FingerPaint extends Activity implements ColorPickerDialog.OnColorChangedListener {

private Paint mPaint; private MyView mView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout main = new LinearLayout(this);
    mView = new MyView(this);
    main.addView(this.getLayoutInflater().inflate( R.layout.topbar, null ));
    main.addView(mView);
    main.bringChildToFront(mView);
    setContentView(main);
   // mView.addView(this.getLayoutInflater().inflate( R.layout.topbar, null ));

    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setDither(true);
    mPaint.setColor(0xFFFF0000);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeJoin(Paint.Join.ROUND);
    mPaint.setStrokeCap(Paint.Cap.ROUND);
    mPaint.setStrokeWidth(12);
    mBitmaps=new Bitmap[100];
    location=0;
    actualSize=0;
    mEmboss = new EmbossMaskFilter(new float[] { 1, 1, 1 },
                                   0.4f, 6, 3.5f);
    mBlur = new BlurMaskFilter(8, BlurMaskFilter.Blur.NORMAL);
    setContentView(main);
}

public class MyView extends View{ ......... }

But when run, only the topbar.xml view is shown. I want the status bar from topbar and the rest down to be from the myView (for drawing on the screen like paint). Am I using ViewGroup properly?

© Stack Overflow or respective owner

Related posts about layout

Related posts about custom