vyshas Posted June 28, 2012 Share Posted June 28, 2012 I would like to place a custom view in the bottom of the main.xml file.following is my Activity class and my custom view class(game.java):I want the game view to appear on the bottom of the main.xml file.Please tell me how to get on with it....I think the idea is to have a layout set in main.xml and then have the custom view on the layout.My main objective is to have the custom view appear on bottom half of main.xml layout.Please help me!!!!! //LearningActivity.java public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //For custom view setContentView(R.layout.main); RelativeLayout r=(RelativeLayout) findViewById(R.id.relative1); g=new game(this,null); ViewGroup vgroup=(ViewGroup) findViewById(R.id.main); vgroup.addView(g); Thread mythread=new Thread(new UpdateThread()); mythread.start(); } //Game.java(custom view) public class game extends View{ private Bitmap image; private Paint paint; private int x=0;private int baseY = 250; public game(Context context,AttributeSet attrs) { super(context,attrs); this.inflate(context, R.layout.example, null); image=Bitmap.createBitmap(BitmapFactory.decodeResource(this.getResources(),R.drawable.ic_launcher)); paint =new Paint(); paint.setColor(Color.BLUE); } public View getlay (RelativeLayout r) { return r; } public void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.drawLine(90, baseY,200,baseY, paint); canvas.drawLine(125,baseY,125,baseY-100,paint); canvas.drawLine(110,baseY,125,baseY-15,paint); .................. } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.