Wednesday, 2 October 2013

Relative lyaout in Android

Relative lyaout in Android

I am making an android app for diabetic patients. In that app I want to
show the food item with their quantity for every meal for diet control. It
should look somewhat like below:
RICE 100gm
POTATO 50gm
FISH 60gm
Those info will be obtained from my database dynamically. However I am
facing problem arranging them. I want the food items to be aligned left
and quantity aligned right of the screen. As below (dots denote the screen
)
|-------------------------------------------------------|
|RICE 100gm |
|POTATO 50gm |
|FISH 60gm |
|-------------------------------------------------------|
To do that I have declared a relative Layout in xml file. The code looks
as below :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</RelativeLayout>
</LinearLayout>
All I need to do now is to create textview and add them to this relative
layout dynamically. But I am confused how to do that. Any hint please...
The final output should look something like below :

No comments:

Post a Comment