Android的:如何改变layout_x,layout_y在AbsoluteLayout动态? [英] Android: how to change layout_x, layout_y in an AbsoluteLayout dynamically?

查看:351
本文介绍了Android的:如何改变layout_x,layout_y在AbsoluteLayout动态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个固定的背景图片并显示在顶部的另一个形象。
这里是XML -

I have a fixed background-image and showing another image on top of it. Here is the xml-

<AbsoluteLayout 
  xmlns:android="http://schemas.android.com/apk/res/android" 
  android:orientation="vertical" 
  android:layout_width="wrap_content" 
  android:layout_height="wrap_content"
  >
 <ImageView 
     android:id="@+id/test_image"
     android:src="@drawable/lpch_1"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
        />
<ImageView 
     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"
        />  
 </AbsoluteLayout>

现在,我可以怎样改变layout_x,从code图像-ID search_pin的layout_y?

Now, how can I change the layout_x, layout_y of image-id search_pin from code?

推荐答案

试试这个:

AbsoluteLayout.LayoutParams params = ((AbsoluteLayout.LayoutParams) test_image.getLayoutParams());
params.x = 100;
params.y = 100;
test_image.setLayoutParams(params); 

这篇关于Android的:如何改变layout_x,layout_y在AbsoluteLayout动态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆