Android的TextView中使用的标签和值 [英] Android textview usage as label and value

查看:122
本文介绍了Android的TextView中使用的标签和值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想组一组的两个textviews和使用像标签和值。有没有为组元组中的android 2 textviews?怎么能在Android的布局来实现?

I want to group two textviews in a group and use like a label and value. Is there any componenet to group two textviews in android? How can it be accomplished in android layout?

推荐答案

您可以使用<的LinearLayout> 来族元素horizo​​ntaly。你也应该使用样式来设置页边距,背景和其他属性。这将允许你不要重复$ C $下您使用的每个标签。 下面是一个例子:

You can use <LinearLayout> to group elements horizontaly. Also you should use style to set margins, background and other properties. This will allow you not to repeat code for every label you use. Here is an example:

<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>

你也可以创建上面布局的自定义视图的基础。 你看创建自定义视图

Also you can create a custom view base on the layout above. Have you looked at Creating custom view ?

这篇关于Android的TextView中使用的标签和值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆