布局浮在另一个布局Android,android – 如何在我的情况下将一个布局嵌入另一个布局?...

如果我有一个名为bottom.xml的布局,

bottom.xml :(只包含一个textview和编辑文本视图)

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center_horizontal"

android:orientation="vertical"

>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center_horizontal"

android:gravity="center_horizontal"

android:text="@string/username"

/>

android:id="@+id/name"

android:layout_width="120dip"

android:layout_height="50dip"

android:layout_gravity="center_horizontal"

/>

有没有办法将上面的bottom.xml布局嵌入到其他布局中,而不是在几个布局文件中重复编写相同的代码(当其他布局的部分包含与bottom.xml相同的布局时)?

例如,如果我的admin.xml布局还包含与bottom.xml完全相同的部分布局,那么如何在bottom.xml中嵌入bottom.xml而不是再次编写相同的代码?

admin.xml的:

android:layout_width="wrap_content"

android:layout_height="wrap_content"

>

...

...

...

如果在Android中无法做到这一点,可能是什么方法?

———- ———–更新

像@xevincent建议的那样,我可以通过使用< include>来重用bottom.xml.标签,

但是如何更改已恢复布局中元素的ID?

例如,insdie bottom.xml,我想更改< editText android:id =“@ id / name”>的id. to< editText android:id =“@ id / other_name”>当我在其他布局中重用bottom.xml布局时,如何更改id?

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值