2

I'm trying align a text with the params of Framelayout using bottom and right but is not working. Here's the code:

FrameLayout frame = (FrameLayout)findViewById(R.id.frame1);

TextView text = (TextView)frame.findViewById(R.id.text);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(100, 100);
params.setMargins(0,0,100,100);     
text.setLayoutParams(params);

The default align of FrameLayout is top and left margins, but on my application i have to use bottom and right.

Dirceu
  • 71
  • 1
  • 9

2 Answers2

3

I am not sure if this will work , could you try to put this

 params.gravity = (Gravity.BOTTOM |Gravity.RIGHT);

please leave a comment if it does or dosent' work for you

Good luck

Netero
  • 3,761
  • 2
  • 29
  • 29
1

you forgot to set a FrameLayout.LayoutParams gravity, like below:

 params.gravity = (Gravity.BOTTOM |Gravity.RIGHT);

Hope it help.

piotrek1543
  • 19,130
  • 7
  • 81
  • 94
  • chack also: http://stackoverflow.com/questions/8101532/android-set-margins-in-a-framelayout-programmatically-not-working – piotrek1543 Jan 08 '16 at 19:58