0

The below code needs API 11 - how would I write this to support API level 1? I just want to relocate a view.

ImageView imageviewLogo = (ImageView)findViewById(R.id.imageViewLogo);
imageviewLogo.setY(imageviewLogo.getHeight());
Jonny
  • 15,955
  • 18
  • 111
  • 232
  • 1
    Not that it will help for this particular method, but do you really need to support API level 1? I would start at 10 for anything new, or even 15 if it was a few months before I expected to release. A more recent API level will save you a lot of time and frustration, assuming you don't absolutely _need_ API 1 (to support an HTC Dream that hasn't been updated?). – jbowes Nov 06 '12 at 11:03

1 Answers1

0

You'd need to update the margins and use that to relocate the view. Here is a good example taken from here:

LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
lp.setMargins(left, top, right, bottom);
imageView.setLayoutParams(lp);

and perhaps invalidate layout after the margins are updated.

Community
  • 1
  • 1
Warpzit
  • 27,966
  • 19
  • 103
  • 155