Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android textview usage as label and value

Tags:

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

Sample label value

like image 854
hkutluay Avatar asked Nov 27 '12 11:11

hkutluay


1 Answers

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 ?

like image 128
k_shil Avatar answered Oct 08 '22 08:10

k_shil