English 中文(简体)
我有两口相色。 有可能动态改变一个图像格的位置。 而后者则保持不变?
原标题:I have a two imageView in a Relative Layout. Is it possible to change the Position of one imageview dynamically. while the other remain constant.?

I have Two Image Views Defined in Xml. I want to Change the Position of One of them Dynamically while the Other remains constant.?? Any Suggestions. Thanx.

最佳回答

当然,这是可能的。 Use LayouParam

        ImageView img1=(ImageView) findViewById(R.id.imageview);
    ImageView img2=(ImageView) findViewById(R.id.imageview);

    RelativeLayout.LayoutParams lp2=new RelativeLayout.LayoutParams(100, 100);
    lp2.addRule(RelativeLayout.ALIGN_RIGHT,img2.getId());
    img1.setLayoutParams(lp2);

<>Setting Margin

lp2.setMargins(Left, TOp, right,Bottom);
问题回答

你们可以通过为<编码>提供新的规则来做到这一点。 类似情况:

RelativeLayout.LayoutParams params = imageView2.getLayoutParams();
params.addRule(RelativeLayout.CENTER_IN_PARENT);
imageView2.setLayoutParams(params);

让我们塑造你们的形象 意见1 联系中心由母体组成。 你们的第二次形象 观点2与图像1保持一致,现在,你希望将其与形象以下保持一致。 观点1。 实现以下目标:

RelativeLayout.LayoutParams params = imageView2.getLayoutParams(); param.addRule(RelativeLayout.BELOW, R.id.imageView1); imageView2.setLayoutParams(params);

Use the layout property like this:

imageView.layout(l,t,r,b);

<代码>l 页: 1





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签