我有一个固定的背景图像,并在其上显示另一个图像.
这是xml-
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
android:id="@+id/test_image"
android:src="@drawable/lpch_1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
android:id="@+id/search_pin"
android:src="@drawable/pin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_y="100px"
android:layout_x="100px"
/>
现在,我如何从代码中更改image-id search_pin的layout_x,layout_y?
解决方法:
试试这个:
AbsoluteLayout.LayoutParams params = ((AbsoluteLayout.LayoutParams) test_image.getLayoutParams());
params.x = 100;
params.y = 100;
test_image.setLayoutParams(params);
标签:android,android-layout,absolutelayout
来源: https://codeday.me/bug/20190610/1209475.html