I have declared textview in relative layout with marginleft and marigntop declared with 30dp. But i need to change those marginleft and margintop dynamically inside class file for one particular thing. Help how to do it.
thanks in advance!!!!!111111
I have declared textview in relative layout with marginleft and marigntop declared with 30dp. But i need to change those marginleft and margintop dynamically inside class file for one particular thing. Help how to do it.
thanks in advance!!!!!111111
TextView forgot_pswrd = (TextView) findViewById(R.id.ForgotPasswordText);
forgot_pswrd.setOnTouchListener(this);
LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
llp.setMargins(30, 0, 0, 0); // llp.setMargins(left, top, right, bottom);
forgot_pswrd.setLayoutParams(llp);
I did this and it worked perfectly. Maybe as you are giving the value in -ve, that's why your code is not working. You just put this code where you are creating the reference of the view.