我想将两个文本视图分组为一个组并使用标签和值。 android中是否有任何组件可以将两个textview分组?在android布局中如何实现呢?
您可以使用<LinearLayout>
将元素水平分组。此外,您还应该使用样式来设置边距、背景和其他属性。这将使您不必为您使用的每个标签重复代码。
这是一个例子:
<LinearLayout
style="@style/FormItem"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
style="@style/FormLabel"
android:layout_width="wrap_content"
android:layout_height="@dimen/default_element_height"
android:text="@string/name_label"
/>
<EditText
style="@style/FormText.Editable"
android:id="@+id/cardholderName"
android:layout_width="wrap_content"
android:layout_height="@dimen/default_element_height"
android:layout_weight="1"
android:gravity="right|center_vertical"
android:hint="@string/card_name_hint"
android:imeOptions="actionNext"
android:singleLine="true"
/>
</LinearLayout>
您还可以根据上面的布局创建自定义视图。
你看过吗创建自定义视图 http://developer.android.com/training/custom-views/create-view.html ?
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)