• Post Reply Bookmark Topic Watch Topic
  • New Topic

relativelayout.layoutparams not being applied to view  RSS feed

 
john bean
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cant figure why these params are not being applied buttonp works and the view is in the right place but letp dont seem to do anything the view is small and placed i the top left of the screen not the center and stretched to matchparent cant figure it out anyway here is the code any help would be great thanks..


 
Giovanni Montano
Ranch Hand
Posts: 326
4
Android Open BSD Slackware
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why are you pinpointing your button with this?
Button returnbut=new Button(this);


It is not java, if you pass this will be called I am afraid an instance of the Activity!
you need to refer your button with 
findViewById(R.id.NameOfYourButton)

this is how android coders do, also notice that in real life you will see this referenced by mean of  a library called Butterknife
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!