views:

387

answers:

3

I have a TextView that I created in the main.xml. In my app.java I am dynamically positioning that TextView based on where the user taps the screen. The problem I am having is that when I call myTextView.setPadding(100,100,0,0), it moves the actual Text of the TextView, but does not move the Colored Background of the TextView.

Ideas?

A: 

The padding only affect the contents of the View, you could embed your View inside a LinearLayout and change the padding of the LinearLayout to move the TextView.

stealthcopter
A: 

If you want to move the entire contents you might want to use margins instead.

jqpubliq
A: 

You may use animation to move a view.

Animation a = new TranslateAnimation((oldPos),
                 newPos, 0.0f, 0.0f);
        a.setDuration(300);
        a.setStartOffset(100);
        a.setRepeatMode(Animation.ABSOLUTE);
        a.setFillAfter(true);

        a.setInterpolator(AnimationUtils.loadInterpolator(this.getContext(),
                        android.R.anim.accelerate_decelerate_interpolator));

 View.startAnimation(a);
herbertD