0

I have a textview that must be put in center of screen in relative layout.

TextView displays random question, when i select answers, new text is put in the textview.

The very first time activity runs, it stays somewhat off the center, but as i answer questions, it starts staying in the right place.

I can't use "center in parent" attr. I don't have any other params for this textview.

class M extends Activity{

@Override
public void onCreate(){
        question1 = (TextView) findViewById(R.id.question1);

        //this relative layout params should be applied right away! but they don't
        for_question1 = new RelativeLayout.LayoutParams(600,200);
        for_question1.setMargins(635, 365, 0, 0);
        question1.setLayoutParams(for_question1);
        question1.requestLayout();

}
}
ERJAN
  • 23,696
  • 23
  • 72
  • 146

1 Answers1

0

I solved it, dont' know how, but I deleted the textView and created same from scratch and it worked. Very often this is the best thing to do.

ERJAN
  • 23,696
  • 23
  • 72
  • 146