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