如何夸大一个视图与布局 [英] How to inflate one view with a layout

查看:114
本文介绍了如何夸大一个视图与布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在XML中定义的布局。它还包含:

I have a layout defined in XML. It contains also:

<RelativeLayout
    android:id="@+id/item"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
/>

我想夸大这种RelativeView与其它的XML布局文件。我可以用根据情况不同的布局。我应该怎么办呢?我尝试了

I would like to inflate this RelativeView with other XML layout file. I may use different layouts depending on a situation. How should I do it? I was trying different variations of

RelativeLayout item = (RelativeLayout) findViewById(R.id.item);
item.inflate(...)

但他们没有工作的罚款。 Heeelp;)

But none of them worked fine. Heeelp ;)

推荐答案

我不知道我按照您的问卷,你试图附加子视图的RelativeLayout的?如果是这样,你想要做线沿线的东西:

I'm not sure I have followed your question- are you trying to attach a child view to the RelativeLayout? If so you want to do something along the lines of:

RelativeLayout item = (RelativeLayout)findViewById(R.id.item);
View child = getLayoutInflater().inflate(R.layout.child, null);
item.addView(child);

这篇关于如何夸大一个视图与布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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