I have a RelativeLayout
within a ScrollView
, I am trying to move the textView, move it down or to the right but I can not find the way.
I tried with:
valueTV.setPadding(200, 500, 40, 100);
But the textView does not change its place
Paste my code:
RelativeLayout layout = (RelativeLayout) findViewById(R.id.layout);
TextView valueTV = new TextView(this);
valueTV.setText("try txtVw");
valueTV.setBackgroundColor(Color.CYAN);
valueTV.setLayoutParams(new LayoutParams( 30,20));
// valueTV.setPadding(200, 500, 40, 100); //It doesn't work//
layout.addView(valueTV);
Thanks!
I think it will help you. try this.
TextView tv;
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
lp.rightMargin = //RIGHTMARGIN;
lp.leftMargin = //LEFT MARGIN;
lp.topMargin = // TOP MARGIN;
lp.bottomMargin = // BOTTOM MARGIN;
layout.addView(tv, lp);