[英]Android: how to 'insert' a layout into another layout?
I wasn't quite sure on how to ask this, but it would essentially be the equivalent of a custom directive in HTML, pseudo code below: 我不太确定如何提出此要求,但是从本质上讲,它等效于HTML中的自定义指令,下面是伪代码:
Main layout 主要布局
<RelativeLayout>
<TextView text="Our song list"/>
<LinearLayout>
<CustomLayoutHere>
</LinearLayout>
</RelativeLayout>
Custom layout 自定义布局
<LinearLayout orientation="horizontal>
<TextView text="Song name:"/>
<ImageView background="albumart.png"/>
<Button text="Add to favorites"/>
</LinearLayout>
So essentially this custom layout piece would be added into the LinearLayout above, once for each song. 因此,基本上,此自定义布局片段将被添加到上面的LinearLayout中,每首歌曲一次。
Use the include
tag: 使用
include
标记:
<RelativeLayout>
<TextView text="Our song list"/>
<LinearLayout>
<include layout="@layout/custom_layout"/>
</LinearLayout>
</RelativeLayout>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.