I have a FrameLayout that has 2 images, a large one that fills the FrameLayout and a very small one that I want to move.
I'm trying to move a small one like this: xml file
<FrameLayout android:id="@+id/layTrackMap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone">
<ImageView android:id="@+id/imgTrackMap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<ImageView android:id="@+id/imgPosition"
android:layout_width="wrap_content"
android:src="@drawable/position"
android:layout_height="wrap_content"
/>
</FrameLayout>
and code:
imgPosition = (ImageView)findViewById(R.id.imgPosition);
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
lp.leftMargin=30;
lp.topMargin=80;
imgPosition.setLayoutParams(lp);
Small image does not move. I want to be able to move a small image around the layout.
LATER CHANGE: After trying a few tips, I came to the conclusion that it is easier to just make your own view and override onDraw to complete the task.
source
share