我在想,如果以下可以在XML来实现:是否有可能将视图添加到xml包含的布局?
我有这个简单的布局类似以下内容:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Address: "
android:textSize="14dp" />
</LinearLayout>
当我有这个布局在其他的XML,是可以添加其他的TextView中它,所以结果将如下所示:
地址:另一个textview的文本。
我想在xml中完成此操作,而不是通过编程方式。
我尝试以下操作:
<include layout="@layout/mybaselayout" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:text="mylocalizedstring" />
</include>
这不工作,我会尝试一些不可能在这里XML做什么?
谢谢。
如果我没有弄错,你应该可以把textview放在当前的下方。 – sbrichards 2012-07-31 06:36:33
然后,你应该添加textView到这个布局......但我会说,以编程方式会更容易做到这一点。 – yahya 2012-07-31 06:36:39
但我有这样的情况,就像有40个本地化的字符串用于第二个文本,但第一个文本总是相同的。所以我试图使用更少的代码。 – Niko 2012-07-31 06:41:20