android中改变x坐标,Android:如何动态更改AbsoluteLayout中的layout_x,layout_y?

我有一个固定的背景图像,并在其上显示另一个图像.

这是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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值