将影像(叠加)在X,另一幅图像的Y(背景) [英] Place an Image (overlay) over x,y of another image(background)

查看:139
本文介绍了将影像(叠加)在X,另一幅图像的Y(背景)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要动态地放置图像在运行时对其它图像precisely在x,背景图像的Y

我有以下细节:

叠印图像属性(红色):X = 58,Y = 232,H = 266,W = 431
背景图像(黑色):match_parent,W = 1024,H = 768

这里的x,y是覆盖层的左上角。

注:X,叠加图像y是相对于背景图像,而不是整个屏幕布局。背景图像可能会拉伸时动作条隐藏。背景图像的layout_width和layout_height设为match_parent。而scaleType是中心。

与下面code:

  @覆盖
保护无效的onCreate(包savedInstanceState){
    super.onCreate(savedInstanceState);

    的setContentView(R.layout.activity_main);

    RelativeLayout的根=(RelativeLayout的)findViewById(R.id.rootlayout);

    backIV =(ImageView的)findViewById(R.id.imageView1);

    内容=新ImageView的(这一点);
    Content.setImageDrawable(getResources()getDrawable(R.drawable.content_1));
    PARAMS =新RelativeLayout.LayoutParams(431,266);

    rl.addView(内容,则params);

    root.addView(RL);


}
 

  

从code以上

  

[我要什么]

从这么多的解决方案和建议,没有为我工作。相信我,我不是张贴了这个问题,但不尝试任何事情。

解决方案

看我的回答这个问题:<一href="http://stackoverflow.com/questions/16729169/how-to-maintain-multi-layers-of-imageviews-and-keep-their-aspect-ratio-based-on">How保持ImageViews多层次和不断的基础上规模最大的一次他们的长宽比?

这是一个支持多绘制对象层的延伸ImageView的

I need to place an image dynamically at runtime on another Image precisely at x,y of the background Image.

I have the following details:

Overlay Image Attributes(Red): x = 58, y =232, h=266, w=431
Background Image(Black): match_parent, w=1024,h=768

Here x,y is the top left corner of the overlay.

Note: The x,y of the Overlay image is with respect to the background image and not the entire screen layout. The background image might get stretched when the ActionBar is hidden. The layout_width and layout_height of the background image is set to match_parent. and the scaleType is "center".

with the below code:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);

    RelativeLayout root = (RelativeLayout) findViewById(R.id.rootlayout);

    backIV = (ImageView) findViewById(R.id.imageView1);

    Content = new ImageView(this);
    Content.setImageDrawable(getResources().getDrawable(R.drawable.content_1));
    params = new RelativeLayout.LayoutParams(431, 266);

    rl.addView(Content, params);

    root.addView(rl);


}

From the code above:

[What i want]

From many solutions and suggestions on SO, none worked for me. Believe me, am not posting this question without trying anything.

解决方案

see my answer for this question: How to maintain multi layers of ImageViews and keep their aspect ratio based on the largest one?

this is an extended ImageView that supports multiple Drawable layers

这篇关于将影像(叠加)在X,另一幅图像的Y(背景)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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