Design of android xml layout - android

I trying to design android listView like image below
But I get this
How to make the timeOut display beside timeIn and have a line between timeIn and timeOut ? Thanks.
xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="6dip">
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Description : "
android:layout_below="#+id/textView3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView2"
android:layout_below="#+id/Project"
android:text=" Progress : "/>
<TextView
android:id="#+id/Project"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:textStyle="bold"
android:text=" Project "
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:id="#+id/Description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView2"
android:layout_alignBottom="#+id/textView2"
android:layout_toRightOf="#+id/textView2"
android:text="TextView" />
<TextView
android:id="#+id/Percentage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView3"
android:layout_alignBottom="#+id/textView3"
android:layout_toRightOf="#+id/textView3"
android:text="TextView" />
<TextView
android:id="#+id/in"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TimeIn"
android:paddingLeft="80dp"
android:layout_toRightOf="#+id/Project"
android:layout_alignParentRight="true"
android:layout_marginRight="64dp" />
<TextView
android:id="#+id/out"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TimeOut"
android:layout_toRightOf="#+id/in"
android:layout_alignParentRight="true" />
</RelativeLayout>

Please try this xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="#dimen/activity_horizontal_margin">
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/textView3"
android:text="Description : "/>
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView2"
android:layout_below="#+id/Project"
android:text="Progress : "/>
<TextView
android:id="#+id/Project"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:text="Project "
android:textColor="#color/colorBlack"
android:textStyle="bold"/>
<TextView
android:id="#+id/Description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView2"
android:layout_alignBottom="#+id/textView2"
android:layout_toRightOf="#+id/textView2"
android:text="TextView"/>
<TextView
android:id="#+id/Percentage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView3"
android:layout_alignBottom="#+id/textView3"
android:layout_toRightOf="#+id/textView3"
android:text="TextView"/>
<TextView
android:id="#+id/in"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/out"
android:text="TimeIn | "/>
<TextView
android:id="#+id/out"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="TimeOut"/>
</RelativeLayout>
Hope it will help..!!

You are using android:layout_alignParentRight="true" for both your #+id/out and #+id/in TextViews.
Use it only for the one that would appear on the right, which in your case is timeOut. Timein TextView should use android:layout_toLeftOf of timeout TextView.
If you want to use a line between them, you can either use another TextView with "|" between them, or you can draw a View there.

Try this
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#android:color/darker_gray"
android:padding="6dip">
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/textView3"
android:text=" Description : "
android:textColor="#android:color/black" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView2"
android:layout_below="#+id/Project"
android:text=" Progress : "
android:textColor="#android:color/black" />
<TextView
android:id="#+id/Project"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:text=" Project "
android:textColor="#android:color/black"
android:textStyle="bold" />
<TextView
android:id="#+id/Description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView2"
android:layout_alignBottom="#+id/textView2"
android:layout_toRightOf="#+id/textView2"
android:text="TextView"
android:textColor="#android:color/black" />
<TextView
android:id="#+id/Percentage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView3"
android:layout_alignBottom="#+id/textView3"
android:layout_toRightOf="#+id/textView3"
android:text="TextView"
android:textColor="#android:color/black" />
<LinearLayout
android:id="#+id/container"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/in"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/line"
android:text="TimeIn"
android:textColor="#android:color/black" />
<LinearLayout
android:id="#+id/line"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_toLeftOf="#+id/out"
android:background="#android:color/black"
android:orientation="horizontal">
</LinearLayout>
<TextView
android:id="#+id/out"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="TimeOut"
android:textColor="#android:color/black" />
</LinearLayout>
</RelativeLayout>
Output of this code

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="6dip">
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/textView3"
android:text=" Description : " />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView2"
android:layout_below="#+id/Project"
android:text=" Progress : " />
<TextView
android:id="#+id/Project"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:text=" Project "
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:orientation="horizontal">
<TextView
android:id="#+id/in"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TimeIn" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" | " />
<TextView
android:id="#+id/out"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TimeOut" />
</LinearLayout>

Related

how to align text in textview Object in Android

I am trying to presnt the text that was back from the server on the UI. i succedd to get the data but for some reason my date (textViewDate) is not begin with the other lines such as place (textViewPlace) and time (textViewTime).
how can i align it in a proper way?
this is my xml code:
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/relativlayoutGcmMessage"
android:background="#ffffff">
<TextView
android:id="#+id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="this is the message"
android:textSize="20sp"
android:layout_below="#+id/textViewUser"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_above="#+id/textViewloc" />
<LinearLayout
android:id="#+id/linearLayoutBtn"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:layout_marginTop="20dp"
android:layout_below="#+id/separatorDown"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<Button android:text="Join"
android:id="#+id/ButtonJoin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:background="#606060"
android:layout_below="#+id/linearLayoutBtn"
android:layout_toRightOf="#+id/textViewUser"
android:layout_toEndOf="#+id/textViewUser">
</Button>
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:id="#+id/separatorUp"
android:visibility="visible"
android:background="#FF0000"
android:layout_marginTop="25dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:id="#+id/separatorDown"
android:visibility="visible"
android:background="#FF0000"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="User ,"
android:id="#+id/textViewUser"
android:layout_below="#+id/separatorUp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:textStyle="bold"
android:layout_marginTop="5dp"
android:textSize="20sp"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="When:"
android:id="#+id/textViewWhen"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="#000000"
android:layout_above="#+id/separatorDown"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="45dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Date"
android:id="#+id/textViewDate"
android:textSize="20sp"
android:layout_marginLeft="40dp"
android:layout_alignTop="#+id/textViewWhen"
android:layout_toRightOf="#+id/textViewUser"
android:layout_toEndOf="#+id/textViewUser" />
<Button android:text="Deny"
android:id="#+id/ButtonDeny"
android:layout_width="361dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:textColor="#ffffff"
android:background="#606060"
android:layout_below="#+id/linearLayoutBtn"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
</Button>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Between:"
android:id="#+id/textViewbtwn"
android:textColor="#000000"
android:textStyle="bold"
android:textSize="20sp"
android:layout_below="#+id/textViewDate"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Time"
android:id="#+id/textViewtime"
android:layout_marginLeft="10dp"
android:textSize="20sp"
android:layout_below="#+id/textViewDate"
android:layout_toRightOf="#+id/textViewbtwn"
android:layout_toEndOf="#+id/textViewbtwn" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Location:"
android:id="#+id/textViewloc"
android:layout_above="#+id/textViewWhen"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:textStyle="bold"
android:textColor="#000000"
android:textSize="20sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="place"
android:id="#+id/textViewPlace"
android:layout_above="#+id/textViewDate"
android:layout_alignLeft="#+id/textViewtime"
android:layout_alignStart="#+id/textViewtime"
android:textSize="20sp" />
</RelativeLayout>
this is how its look like on my device:
Add this layoute Like this:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Date"
android:id="#+id/textViewDate"
android:textSize="20sp"
android:layout_alignTop="#+id/textViewWhen"
android:layout_toRightOf="#+id/textViewUser"
android:layout_toEndOf="#+id/textViewUser" />
in This code has Remove This Line..
android:layout_marginLeft="40dp"
I think its Work.
Use a Table layout
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Location:"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="place"
/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="When:"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Date"
/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Between:"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Time"
/>
</TableRow>
</TableLayout>
Also remove the margin property from DATE text.

Align Text and Images perfectly next to Each Other

I am trying to line up the text and images next to each other in a perfect line but cant quite get it center.
As you see with the image it's almost center next to each other but not perfectly what am I missing
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" >
<TextView
android:id="#+id/textView1"
android:textSize="14dp"
android:textStyle="bold"
android:gravity="center_vertical"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<ImageView
android:id="#+id/imageView1"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/textView1"
android:layout_gravity="center_vertical|right"
android:gravity="center_vertical|right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/image_ls"
/>
<TextView
android:id="#+id/textView2"
android:textSize="14dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:textStyle="bold"
android:layout_toRightOf="#+id/imageView1"
android:layout_gravity="center_vertical|right"
android:gravity="center_vertical|right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
/>
<ImageView
android:id="#+id/imageView2"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/textView2"
android:layout_gravity="center_vertical|right"
android:gravity="center_vertical|right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/image_ls"
/>
<TextView
android:id="#+id/textView3"
android:layout_toRightOf="#+id/imageView2"
android:layout_gravity="center_vertical|right"
android:gravity="center_vertical|right"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:textSize="14dp"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
/>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="10dp">
<TextView
android:id="#+id/textView1"
android:textSize="14dp"
android:textStyle="bold"
android:gravity="center_vertical"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<ImageView
android:id="#+id/imageView1"
android:layout_marginLeft="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="#drawable/image_ls" />
<TextView
android:id="#+id/textView2"
android:textSize="14dp"
android:layout_marginLeft="5dp"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="TextView" />
<ImageView
android:id="#+id/imageView2"
android:layout_marginLeft="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="#drawable/image_ls" />
<TextView
android:id="#+id/textView3"
android:textSize="14dp"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="TextView" />
</LinearLayout>
Try This Code:-
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" >
<TextView
android:id="#+id/textView1"
android:textSize="14dp"
android:textStyle="bold"
android:gravity="center"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<ImageView
android:id="#+id/imageView1"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/textView1"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/image_ls"
/>
<TextView
android:id="#+id/textView2"
android:textSize="14dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:textStyle="bold"
android:layout_toRightOf="#+id/imageView1"
android:layout_centerVertical="true"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
/>
<ImageView
android:id="#+id/imageView2"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/textView2"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/image_ls"
/>
<TextView
android:id="#+id/textView3"
android:layout_toRightOf="#+id/imageView2"
android:layout_centerVertical="true"
android:gravity="center_vertical|right"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:textSize="14dp"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
/>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:text="TextView"
android:textSize="14dp"
android:textStyle="bold" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical|right"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|right"
android:text="TextView"
android:textSize="14dp"
android:textStyle="bold" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|right"
android:gravity="center_vertical|right"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|right"
android:text="TextView"
android:textSize="14dp"
android:textStyle="bold" />
</LinearLayout>
Try this:
Use LinearLayout to fix android widgets in vertical or horizontal.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:textSize="14dp"
android:textStyle="bold" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:textSize="14dp"
android:textStyle="bold" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:src="#drawable/ic_launcher" />

How to design this layout to fit all screen sizes in android?

I need to design this above layout which should fit all screen size
Here b1 and b2 are buttons.
Which layout should i use relative or linear?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="Button" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="Button" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/button1"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView1"
android:layout_below="#+id/textView1"
android:layout_marginTop="20dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/textView2"
android:layout_below="#+id/textView2"
android:layout_marginTop="20dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView3"
android:layout_below="#+id/textView3"
android:layout_marginTop="20dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView4"
android:layout_below="#+id/textView4"
android:layout_marginTop="20dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
</RelativeLayout>
use this i think this will solve your prob
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView1"
android:layout_below="#+id/textView1"
android:layout_marginTop="20dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/textView2"
android:layout_below="#+id/textView2"
android:layout_marginTop="20dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView3"
android:layout_below="#+id/textView3"
android:layout_marginTop="20dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView4"
android:layout_below="#+id/textView4"
android:layout_marginTop="20dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="Button" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="Button" />
</RelativeLayout>
Most simple solution is use RelativeLayout or
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" > </RelativeLayout>
or LinearLayout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" > </LinearLayout>

Android ScrollView not working properly

I developed an android application in which the scroll-view is not scrolling.. I am posting the code here pls check and if found any error pls help.. Here I used Linear Layout as root and then Scroll-view and Relative Layout inside the scroll-view and ... text-views inside relative layout... but this is not scrolling up..
XML
<?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="fill_parent"
android:background="#color/orange"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/header901"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/green"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:gravity="center">
<TextView
android:id="#+id/headertext901"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_margin="5dp"
android:gravity="center"
android:textColor="#ffffff"
android:textSize="20sp"
android:text="Result"
android:textStyle="bold"
/>
</RelativeLayout>
<ScrollView
android:id="#+id/scrollView901"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical"
android:fillViewport="true">
<RelativeLayout
android:id="#+id/lLayout901"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="16dp"
android:layout_marginTop="22dp"
android:text="Your Destiny number is :" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView1"
android:layout_alignBottom="#+id/textView1"
android:layout_alignParentRight="true"
android:layout_marginRight="44dp"
android:text="TextView" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView1"
android:layout_below="#+id/textView1"
android:layout_marginTop="18dp"
android:text="Your result is loading......" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView3"
android:layout_below="#+id/textView3"
android:layout_marginTop="16dp"
android:text="Your Talent Number is :" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView4"
android:layout_alignBottom="#+id/textView4"
android:layout_alignLeft="#+id/textView2"
android:text="TextView" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView4"
android:layout_below="#+id/textView4"
android:layout_marginTop="20dp"
android:text="Your result is loading......." />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView6"
android:layout_below="#+id/textView6"
android:layout_marginTop="16dp"
android:text="Your Heart Number is :" />
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView7"
android:layout_alignBottom="#+id/textView7"
android:layout_alignLeft="#+id/textView5"
android:text="TextView" />
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView7"
android:layout_centerVertical="true"
android:text="Your result is loading...." />
<TextView
android:id="#+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView9"
android:layout_below="#+id/textView9"
android:layout_marginTop="20dp"
android:text="Your Personality number is :" />
<TextView
android:id="#+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView10"
android:layout_alignLeft="#+id/textView8"
android:text="TextView" />
<TextView
android:id="#+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView10"
android:layout_below="#+id/textView10"
android:layout_marginTop="18dp"
android:text="Your result is loading...." />
<TextView
android:id="#+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView12"
android:layout_below="#+id/textView12"
android:layout_marginTop="18dp"
android:text="Your Minor expression no:" />
<TextView
android:id="#+id/textView14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView13"
android:layout_alignLeft="#+id/textView11"
android:text="TextView" />
<TextView
android:id="#+id/textView15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView13"
android:layout_below="#+id/textView13"
android:layout_marginTop="18dp"
android:text="Your result is loading....." />
<TextView
android:id="#+id/textView16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView15"
android:layout_below="#+id/textView15"
android:layout_marginTop="18dp"
android:text="Your Minor Heart Desire no:" />
<TextView
android:id="#+id/textView17"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView16"
android:layout_alignLeft="#+id/textView14"
android:text="TextView" />
<TextView
android:id="#+id/textView18"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView16"
android:layout_below="#+id/textView16"
android:layout_marginTop="18dp"
android:text="Your result is loading....." />
<TextView
android:id="#+id/textView19"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView18"
android:layout_below="#+id/textView18"
android:layout_marginTop="18dp"
android:text="Your Minor Personality no:" />
<TextView
android:id="#+id/textView20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView19"
android:layout_alignLeft="#+id/textView17"
android:text="TextView" />
<TextView
android:id="#+id/textView21"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView19"
android:layout_below="#+id/textView19"
android:layout_marginTop="18dp"
android:text="Your result is loading....." />
</RelativeLayout>
</ScrollView>
</LinearLayout>
You have used fill parent for your Scrollview height layout
Use android:layout_height="wrap_content" for scrollview
And i am sugesting to use LinearLayout with vertical orientation layout for this kind of use
Remove RelativeLayout with id "header901", it is useless, you can just leave headertext901 withe the main LinearLayout as parent ...
Then remove the following tags from SCrollView :
android:scrollbars="vertical"
android:fillViewport="true"
I would also advise to replace your RelativeLayout with id "lLayout901" by a LinearLayout, and follow #Martin Marconcini's advice to replace fill_parent with match_parent.

my application Screen position chang after click my custum dialog button

I create an application when with a form that contains many field and one of them show a dialog but if i in latest item show in dialog ok button screen move to first or other edittext
and screen position change.
i wont screen position not change after click on the button
thanks for your help
this is my layout code:
** <?xml version="1.0" encoding="utf-8"?>**
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="none"
tools:context=".SabtTavalodActivity" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linearasli"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|top"
android:gravity="center|right"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/spinnerRel"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/txtheadermonasebat"
style="#style/sectionHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:text="MOnasebat: " />
<Spinner
android:id="#+id/spinner"
style="#style/SpinnerCalenderComp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/txtheadermonasebat"
android:layout_toLeftOf="#+id/txtmonasebat"
/>
<!-- android:entries="#array/moshakhasat" -->
<TextView
android:id="#+id/txtmonasebat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/spinner"
android:layout_alignBottom="#+id/spinner"
android:layout_alignParentRight="true"
android:layout_marginRight="24dp"
android:gravity="right"
android:text="monasebat: " />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/txtname"
style="#style/sectionHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:gravity="right"
android:text="Name: " />
<EditText
android:id="#+id/name"
android:inputType="text"
style="#style/EditTextCalenderComp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:textColorHint="#cacaca"
android:ems="10"
android:singleLine = "true"
android:maxLines = "1"
android:lines = "1"
>
</EditText>
<!--
<QuickContactBadge
android:id="#+id/quickContactBadge1"
android:layout_width="75dp"
android:layout_height="75dp"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="#+id/name"
android:src="#drawable/rihanna"
></QuickContactBadge>
-->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:background="#drawable/image_bg"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="#+id/name"
android:layout_marginTop="55sp"
android:padding="3dip" >
<ImageView
android:id="#+id/imgvw32"
android:layout_width="65dip"
android:layout_height="65dip"
android:contentDescription="#string/axpick"
android:src="#drawable/rihanna"
android:scaleType="fitXY"/>
</LinearLayout>
</RelativeLayout>
**<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15sp">
<TextView
android:id="#+id/txtBirtday"
style="#style/sectionHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:gravity="right"
android:paddingTop="10dp"
android:text="Birtday: " />
<Button
android:id="#+id/btnDatePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginTop="55dip"
android:background="#drawable/btn_add_datapicker"
/>
<TextView
android:id="#+id/txtsabtbirthday"
android:background="#drawable/btn_toggle_on_focused_holo_light"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginTop="85sp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:gravity="center"
android:textColorHint="#cacaca" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="25sp" >
<TextView
android:id="#+id/txtsalepish"
style="#style/sectionHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:gravity="right"
android:text="sale pish: " />
<EditText
android:id="#+id/salepish"
android:inputType="text"
android:paddingTop="85dip"
style="#style/EditTextCalenderComp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:ems="10"
android:lines="1"
android:maxLines="1"
android:singleLine="true"
android:textColorHint="#cacaca" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="25sp">
<TextView
android:id="#+id/txtrate"
style="#style/sectionHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:gravity="right"
android:text="alaghe be in fard: " />
<RatingBar
android:id="#+id/ratingBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="65dp"
android:progressDrawable="#drawable/heart_rate" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20sp" >
<TextView
android:id="#+id/txtHeaderAlarm"
style="#style/sectionHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:gravity="right"
android:text="Alarm: " />
<CheckBox
android:id="#+id/AlarmcheckBox1"
style="#style/CheckBoxCalenderComp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/txtHeaderAlarm"
android:text="ErsalMessage" />
<TextView
android:id="#+id/txtsabtAlarm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/AlarmcheckBox1"
android:gravity="right"
android:text="Message: "
android:textColor="#cacaca"
android:textSize="16dp" />
<CheckBox
android:id="#+id/AlarmcheckBoxTarikh"
style="#style/CheckBoxCalenderComp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/txtsabtAlarm"
android:text="ErsalMessage" />
<TextView
android:id="#+id/txtsabtAlarmTarikh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/AlarmcheckBoxTarikh"
android:gravity="right"
android:text="Message: "
android:textColor="#cacaca"
android:textSize="16dp" />
<CheckBox
android:id="#+id/AlarmcheckBoxHardo"
style="#style/CheckBoxCalenderComp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/txtsabtAlarmTarikh"
android:text="ErsalMessage" />
<CheckBox
android:id="#+id/CheckBoxPickSong"
style="#style/CheckBoxCalenderComp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/txtHeaderAlarm"
android:layout_toLeftOf="#+id/AlarmcheckBoxTarikh"
android:text="ErsalMessage" />
<TextView
android:id="#+id/TextPickSong"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/AlarmcheckBox1"
android:layout_toLeftOf="#+id/AlarmcheckBoxTarikh"
android:gravity="right"
android:text="Message: "
android:textColor="#cacaca"
android:textSize="16dp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relMsg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20sp">
<TextView
android:id="#+id/txtHeaderMsg"
style="#style/sectionHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:gravity="right"
android:text="Message: " />
<CheckBox
android:id="#+id/msgcheckBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
style="#style/CheckBoxCalenderComp"
android:layout_below="#+id/txtHeaderMsg"
android:text="ErsalMessage" />
<TextView
android:id="#+id/txtMSgactive"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/msgcheckBox1"
android:gravity="right"
android:text="Message: "
android:textColor="#cacaca"
android:textSize="16dp" />
<CheckBox
android:id="#+id/msgcheckBoxTarikh"
style="#style/CheckBoxCalenderComp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/txtMSgactive"
android:text="ErsalMessage"
/>
<TextView
android:id="#+id/txtMSgactiveTarikh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/msgcheckBoxTarikh"
android:gravity="right"
android:text="Message: "
android:textColor="#cacaca"
android:textSize="16dp" />
<CheckBox
android:id="#+id/msgcheckBoxSaat"
style="#style/CheckBoxCalenderComp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/txtMSgactiveTarikh"
android:text="ErsalMessage"
/>
<TextView
android:id="#+id/txtMSgactiveSaat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/msgcheckBoxSaat"
android:gravity="right"
android:text="Message: "
android:textColor="#cacaca"
android:textSize="16dp" />
</RelativeLayout>
<TextView
android:id="#+id/txtNote"
android:layout_width="fill_parent"
style="#style/sectionHeader"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/padding_small"
android:layout_marginTop="25dip"
android:gravity="right"
android:text="Note: " />
<EditText
android:id="#+id/note"
android:inputType="text"
style="#style/EditTextCalenderComp"
android:layout_width="#dimen/textbox"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/padding_small"
android:layout_marginRight="10dip"
android:layout_marginTop="25dip"
android:ems="10"
android:textColorHint="#cacaca"
/>
<Button
android:id="#+id/btnNextScreen"
android:background="#drawable/btn_toggle_holo_light_mosi"
android:layout_width="#dimen/btndim"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="10dip"
android:layout_marginTop="15dip"
android:text="Send to Next Screen" />
</LinearLayout>
**

Categories

Resources