How to make table rows scrollable in android - android

Below given is my layout which is I am using for displaying a table, which have a number of rows. the problem is this table have more no of rows than the screen can contain, so i want rows to be scrollable so that if i scroll down i can reach to the rows which is not visible in current screen.
i used isScrollContainer="true" bur this does not solve my problem
Can you please suggest which property can i use to solve the problem
<TableLayout android:layout_height="wrap_content" android:isScrollContainer="true" >
<RelativeLayout android:layout_width="wrap_content"
android:layout_height="wrap_content" android:gravity="center">
<View android:layout_gravity="center" android:layout_height="30px"
android:background="#android:color/darker_gray"
android:layout_width="400px" />
<TextView android:layout_width="wrap_content" style="#style/styleName"
android:id="#+id/tv_add_ticket" android:text="Update Ticket on Assembloid Space"
android:layout_height="wrap_content" android:layout_marginLeft="5px"
android:layout_marginRight="2px" android:layout_marginTop="2px"
android:layout_marginBottom="2px">
</TextView>
</RelativeLayout>
</TableLayout>
<TableLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20px" android:isScrollContainer="true"
xmlns:android="http://schemas.android.com/apk/res/android"
android:baselineAligned="true" android:background="#565051"
android:layout_marginTop="50px">
<TableRow>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/ticket_status"
android:text="Status " android:layout_column="1" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text=":"
android:layout_column="2" android:layout_marginTop="5px"
android:layout_marginRight="5px" />
<!-- <EditText android:layout_width="250px" android:layout_height="wrap_content"
android:id="#+id/et_ticket_status"></EditText> -->
<Spinner android:layout_width="100px" android:layout_height="wrap_content"
android:id="#+id/spn_up_ticket_status"></Spinner>
</TableRow>
<TableRow>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/ticket_priority"
android:text="Priority" android:layout_column="1" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text=":"
android:layout_column="2" android:layout_marginTop="5px"
android:layout_marginRight="5px" />
<Spinner android:layout_width="200px" android:layout_height="wrap_content"
android:id="#+id/spn_up_ticket_priority"></Spinner>
</TableRow>
<TableRow>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/ticket_summary"
android:text="Summary" android:layout_column="1" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text=":"
android:layout_column="2" android:layout_marginTop="5px"
android:layout_marginRight="5px" />
/>
<EditText android:layout_width="250px" android:id="#+id/et_ticket_summary"
android:layout_height="wrap_content" android:autoText="true">
</EditText>
</TableRow>
<TableRow>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/ticket_discription"
android:text="Discription" android:layout_column="1" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text=":"
android:layout_column="2" android:layout_marginTop="5px"
android:layout_marginRight="5px" />
/>
<EditText android:layout_width="250px" android:id="#+id/et_ticket_Discription"
android:layout_height="wrap_content" android:autoText="true"></EditText>
</TableRow>
<TableRow>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/estimated_hour"
android:text="Estimated Hours" android:layout_column="1" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text=":"
android:layout_column="2" android:layout_marginTop="5px"
android:layout_marginRight="5px" />
/>
<EditText android:layout_width="250px" android:id="#+id/et_estimated_hour"
android:layout_height="wrap_content" android:autoText="true"></EditText>
</TableRow>
<TableRow>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/worked_hour"
android:text="Worked Hours" android:layout_column="1" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text=":"
android:layout_column="2" android:layout_marginTop="5px"
android:layout_marginRight="5px" />
<EditText android:layout_width="250px" android:id="#+id/et_worked_hour"
android:layout_height="wrap_content" android:autoText="true"></EditText>
</TableRow>
<TableRow>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/ticket_comment"
android:text="Comment" android:layout_column="1" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text=":"
android:layout_column="2" android:layout_marginTop="5px"
android:layout_marginRight="5px" />
/>
<EditText android:layout_width="250px" android:id="#+id/et_ticket_comment"
android:layout_height="wrap_content" android:autoText="true">
</EditText>
</TableRow>
<TableRow>
<Button android:layout_width="wrap_content" android:text="Comments"
android:layout_height="wrap_content" android:id="#+id/comment_ticket_button" android:layout_column="1" ></Button>
<Button android:layout_width="wrap_content" android:text="#string/update_ticket"
android:layout_height="wrap_content" android:id="#+id/update_ticket_button" android:layout_column="3"></Button>
</TableRow>
<TextView android:id="#+id/error_ticket_text"
android:layout_centerHorizontal="true" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_below="#+id/login_button" />

You should wrap your TableLayout inside a ScrollView with appropriate height
<ScrollView android:id="#+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="100dp">
<TableLayout..>
</TableLayout>
</ScrollView>

You should use ScrollView as the root layout to solve your problem.

Related

android sdk tablelayout alignment

I have been having problems with my table alignment which I can't fix. It's driving me crazy trying to fix this layout. Here's my main.xml:
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableRow>
<TextView
android:layout_width="40sp"
android:layout_marginTop="30dp"
android:text="From" />
<EditText
android:id="#+id/input"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:ems="10"
android:inputType="numberDecimal|numberSigned" >
<requestFocus />
</EditText>
</TableRow>
<Spinner
android:id="#+id/spinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="To" />
<Spinner
android:id="#+id/spinner2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TableRow>
<Button
android:id="#+id/button1"
android:layout_marginLeft="50dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick"
android:text="Formula" />
<Button
android:id="#+id/button1"
android:layout_marginRight="10dp"
android:layout_width="80dp"
android:layout_column="1"
android:layout_height="wrap_content"
android:onClick="onClick"
android:text="Convert" />
</TableRow>
<TextView
android:id="#+id/output"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/op"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall" />
</TableLayout>
I want it to look like this:
image link here http://imageshack.us/a/img818/5928/3wo5.png
try this
the layout is in there.

How to make one part of view (relativelayout) scroll, but another part not move?

I have a RelativeLayout that is a detail page for search results. It displays a bunch of different TextViews, has a table or two, and also holds a SupportMapFragment. I want that portion to be scrollable. I also have a LinearLayout that holds an EditText and a Button at the bottom of the view that should always be visible at the bottom. It's small, maybe an 1/8th of the total view height, and I just want it to always stay there.
I tried to wrap the layout I want scrolling in a ScrollView, leave the other layout out of that, and then wrap the whole thing in a RelativeLayout. The yields a scrollbar, but it doesn't move more than just a tiny, tiny bit, and when it does, there is a little black space revealed where the SupportMapFragment moves from.
How can I set up my layouts to scroll the portion I want scrolling, and leave the other portion alone? Do I need to convert this whole activity to a FragmentActivity?
The layout file I'm wrangling is here:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/detailFragment"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#D0E4F7"
android:paddingBottom="5dp"
android:paddingLeft="12dp"
android:paddingRight="12dp" >
<ScrollView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_above="#+id/tagVenue"
android:layout_alignParentTop="true"
android:layout_marginBottom="5dp">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#D0E4F7"
android:paddingBottom="5dp"
android:paddingLeft="1dp"
android:paddingRight="1dp" >
<TextView
android:id="#+id/vName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="10dp"
android:text="Fore Street Bar and Grill"
android:textIsSelectable="true"
android:textStyle="bold" />
<TextView
android:id="#+id/vAddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/vName"
android:layout_marginTop="5dp"
android:textIsSelectable="true"
android:text="105 Congress St. \nPortland, ME 04055"/>
<TextView
android:id="#+id/vPhone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/vAddress"
android:textIsSelectable="true"
android:layout_marginTop="5dp"
android:text="207-555-1111"/>
<TextView
android:id="#+id/vWeb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/vPhone"
android:textIsSelectable="true"
android:layout_marginTop="5dp"
android:text="www.xyz.com"/>
<TextView
android:id="#+id/vDistance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="false"
android:layout_alignParentRight="true"
android:layout_below="#+id/map"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:text="100 meters away"
android:textIsSelectable="true" />
<TextView
android:id="#+id/vCuisine"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/vWeb"
android:textIsSelectable="true"
android:layout_marginTop="5dp"
android:text="American, Fusion"/>
<TextView
android:id="#+id/vHours"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/vRating"
android:layout_centerHorizontal="true"
android:layout_marginTop="3dp"
android:text="Hours: 10:00 - 22:00 Currently open!"
android:textIsSelectable="true"
android:textStyle="bold" />
<TextView
android:id="#+id/vRating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/vCuisine"
android:textIsSelectable="true"
android:text="5 Stars"/>
<View
android:id="#+id/dividing_line"
android:layout_height="1dp"
android:layout_width="fill_parent"
android:background="#000000"
android:layout_below="#+id/vHours"
android:layout_marginTop="5dp"/>
<!-- SupportMapFragment -->
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="120dip"
android:layout_height="120dip"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="5dp" />
<TableLayout
android:id="#+id/table1"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_below="#+id/dividing_line"
android:layout_marginTop="5dp">
<TableRow
android:id="#+id/tableRow1a"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="2">
<TextView
android:id="#+id/vtext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_weight=".7"
android:text="text"
android:textIsSelectable="true"
android:textSize="18dp"
android:textStyle="bold" />
<TextView
android:id="#+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_weight="1.3"
android:text="93/100"
android:textIsSelectable="true"
android:textSize="20dp"
android:textStyle="bold" />
</TableRow>
</TableLayout>
<TableLayout
android:id="#+id/table2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/table1"
android:layout_marginTop="5dp" >
<TableRow
android:id="#+id/tableRow1b"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/text3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="text"
android:textIsSelectable="true"
android:textStyle="bold" />
</TableRow>
<TableRow
android:id="#+id/tableRow3b"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/text4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="text"
android:textIsSelectable="true" />
<TextView
android:id="#+id/vTag1Mag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="text"
android:textIsSelectable="true" />
</TableRow>
<TableRow
android:id="#+id/tableRow4b"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/vtext2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="text"
android:textIsSelectable="true" />
<TextView
android:id="#+id/vTag2Mag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="text"
android:textIsSelectable="true" />
</TableRow>
<TableRow
android:id="#+id/tableRow5b"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/vtext3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="text"
android:textIsSelectable="true" />
<TextView
android:id="#+id/vTag3Mag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="text"
android:textIsSelectable="true" />
</TableRow>
<TableRow
android:id="#+id/tableRow6b"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/vtext4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="text"
android:textIsSelectable="true" />
<TextView
android:id="#+id/vTag4Mag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="text"
android:textIsSelectable="true" />
</TableRow>
<TableRow
android:id="#+id/tableRow7b"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/vtext5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="text"
android:textIsSelectable="true" />
<TextView
android:id="#+id/vTag5Mag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="text"
android:textIsSelectable="true" />
</TableRow>
<TableRow
android:id="#+id/tableRow8b"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/vtext6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="text"
android:textIsSelectable="true" />
<TextView
android:id="#+id/vTag6Mag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="text"
android:textIsSelectable="true" />
</TableRow>
</TableLayout>
</RelativeLayout>
</ScrollView>
<RelativeLayout
android:id="#+id/textdlfka"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_below="#+id/detailFragment" >
<EditText
android:id="#+id/text7"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/Button01"
android:hint="#string/search" >
</EditText>
<Button
android:id="#+id/Button01"
android:layout_width="wrap_content"
android:layout_height="40dip"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="#string/search" >
</Button>
</RelativeLayout>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/detailFragment"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#D0E4F7"
android:paddingBottom="5dp"
android:paddingLeft="12dp"
android:paddingRight="12dp" >
<ScrollView
android:id="#+id/scrollview"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_above="#+id/textdlfka"
android:layout_alignParentTop="true"
android:layout_marginBottom="5dp" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#D0E4F7"
android:paddingBottom="5dp"
android:paddingLeft="1dp"
android:paddingRight="1dp" >
<TextView
android:id="#+id/vName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="10dp"
android:text="Fore Street Bar and Grill"
android:textIsSelectable="true"
android:textStyle="bold" />
<TextView
android:id="#+id/vAddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/vName"
android:layout_marginTop="5dp"
android:text="105 Congress St. \nPortland, ME 04055"
android:textIsSelectable="true" />
<TextView
android:id="#+id/vPhone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/vAddress"
android:layout_marginTop="5dp"
android:text="207-555-1111"
android:textIsSelectable="true" />
<TextView
android:id="#+id/vWeb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/vPhone"
android:layout_marginTop="5dp"
android:text="www.xyz.com"
android:textIsSelectable="true" />
<TextView
android:id="#+id/vDistance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="false"
android:layout_alignParentRight="true"
android:layout_below="#+id/map"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:text="100 meters away"
android:textIsSelectable="true" />
<TextView
android:id="#+id/vCuisine"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/vWeb"
android:layout_marginTop="5dp"
android:text="American, Fusion"
android:textIsSelectable="true" />
<TextView
android:id="#+id/vHours"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/vRating"
android:layout_centerHorizontal="true"
android:layout_marginTop="3dp"
android:text="Hours: 10:00 - 22:00 Currently open!"
android:textIsSelectable="true"
android:textStyle="bold" />
<TextView
android:id="#+id/vRating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/vCuisine"
android:text="5 Stars"
android:textIsSelectable="true" />
<View
android:id="#+id/dividing_line"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_below="#+id/vHours"
android:layout_marginTop="5dp"
android:background="#000000" />
<!-- SupportMapFragment -->
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="120dip"
android:layout_height="120dip"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="5dp" />
<TableLayout
android:id="#+id/table1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/dividing_line"
android:layout_marginTop="5dp" >
<TableRow
android:id="#+id/tableRow1a"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="2" >
<TextView
android:id="#+id/vtext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_weight=".7"
android:text="text"
android:textIsSelectable="true"
android:textSize="18dp"
android:textStyle="bold" />
<TextView
android:id="#+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_weight="1.3"
android:text="93/100"
android:textIsSelectable="true"
android:textSize="20dp"
android:textStyle="bold" />
</TableRow>
</TableLayout>
<TableLayout
android:id="#+id/table2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/table1"
android:layout_marginTop="5dp" >
<TableRow
android:id="#+id/tableRow1b"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/text3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="text"
android:textIsSelectable="true"
android:textStyle="bold" />
</TableRow>
<TableRow
android:id="#+id/tableRow3b"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/text4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="text"
android:textIsSelectable="true" />
<TextView
android:id="#+id/vTag1Mag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="text"
android:textIsSelectable="true" />
</TableRow>
<TableRow
android:id="#+id/tableRow4b"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/vtext2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="text"
android:textIsSelectable="true" />
<TextView
android:id="#+id/vTag2Mag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="text"
android:textIsSelectable="true" />
</TableRow>
<TableRow
android:id="#+id/tableRow5b"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/vtext3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="text"
android:textIsSelectable="true" />
<TextView
android:id="#+id/vTag3Mag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="text"
android:textIsSelectable="true" />
</TableRow>
<TableRow
android:id="#+id/tableRow6b"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/vtext4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="text"
android:textIsSelectable="true" />
<TextView
android:id="#+id/vTag4Mag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="text"
android:textIsSelectable="true" />
</TableRow>
<TableRow
android:id="#+id/tableRow7b"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/vtext5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="text"
android:textIsSelectable="true" />
<TextView
android:id="#+id/vTag5Mag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="text"
android:textIsSelectable="true" />
</TableRow>
<TableRow
android:id="#+id/tableRow8b"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/vtext6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="text"
android:textIsSelectable="true" />
<TextView
android:id="#+id/vTag6Mag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="text"
android:textIsSelectable="true" />
</TableRow>
</TableLayout>
</RelativeLayout>
</ScrollView>
<RelativeLayout
android:id="#+id/textdlfka"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/scrollview" >
<EditText
android:id="#+id/text7"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/Button01"
android:hint="#string/search" >
</EditText>
<Button
android:id="#+id/Button01"
android:layout_width="wrap_content"
android:layout_height="40dip"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="#string/search" >
</Button>
</RelativeLayout>
</RelativeLayout>

Achieving the same result without paddingLeft property

<?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="5dip" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginRight="5dip"
android:padding="1dip" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="20dp"
android:text="Total Pregnancies"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="30dp"
android:text="10"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="160dp"
android:text="Full Term"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="75dp"
android:text="11"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="190dp"
android:text="Premature"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="30dp"
android:text="12"
android:textColor="#000000" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/linearLayout1"
android:layout_below="#+id/linearLayout1"
android:layout_marginTop="35dp"
android:padding="1dip" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="20dp"
android:text="Multiples"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="85dp"
android:text="16"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="160dp"
android:text="Living"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="95dp"
android:text="17"
android:textColor="#000000" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/linearLayout1"
android:layout_centerVertical="true"
android:padding="1dip" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="20dp"
android:text="Ab Included"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="70dp"
android:text="13"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="160dp"
android:text="Ab Spontaneous"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="30dp"
android:text="14"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="190dp"
android:text="Ectopics"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="35dp"
android:text="15"
android:textColor="#000000" />
</LinearLayout>
</RelativeLayout>
This is how the screen looks, can anyone tell me how can i achieve this layout. i have come up with the layout, but it seems it does not fit for all screens.
Make the LinearLayout width fill_parent to use the entire width of the screen.
Then for each TextView, set the layout_width to 0dp, and set layout_weight to the proportion of the screen you want that view to have.
In the padding, specify the minimum amount you want between the different cells.
For example, if you want the text to occupy double the space of the numbers, use the following code:
<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="5dip" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginRight="5dip"
android:padding="1dip" >
<TextView
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:text="Total Pregnancies"
android:textColor="#000000" />
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:text="10"
android:textColor="#000000" />
<TextView
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:text="Full Term"
android:textColor="#000000" />
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:text="11"
android:textColor="#000000" />
<TextView
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:text="Premature"
android:textColor="#000000" />
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:text="12"
android:textColor="#000000" />
</LinearLayout>
</RelativeLayout>
Use TableLayout
Here is an example

Android Portions of TextView Invisible

I have some text views in a table layout. When I click a button in my layout parts of the textviews disappear. I have tried restarting eclipse and the emulator a few times, but nothing has changed. I am completely stumped. Any suggestions for why this may be happening? I have posted a before and after screenshot and my xml code for the table layout
Before Click
After Click
Portions of the XML Code...
<TableLayout
android:id="#+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/tv_rank"
android:stretchColumns="1" >
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="#acacac"
android:text="Public"
android:textColor="#000000" />
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#acacac"
android:paddingTop="5dp" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="1.35"
android:text="Parties Thrown:"
android:textColor="#000000"
android:textSize="12dp" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="#+id/tv_PublicPartyAmount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textColor="#000000"
android:textSize="12dp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" parties"
android:textColor="#000000"
android:textSize="8dp" />
</LinearLayout>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.35"
android:text="Average Score:"
android:textColor="#000000"
android:textSize="12dp" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="#+id/tv_PublicAverageScore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textColor="#000000"
android:textSize="12dp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" points"
android:textColor="#000000"
android:textSize="8dp" />
</LinearLayout>
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#acacac"
android:paddingBottom="5dp"
android:paddingTop="5dp" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="1.35"
android:text="Biggest Party:"
android:textColor="#000000"
android:textSize="12dp" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="#+id/tv_PublicBiggestParty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textColor="#000000"
android:textSize="12dp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" guests"
android:textColor="#000000"
android:textSize="8dp" />
</LinearLayout>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.35"
android:text="Highest Score:"
android:textColor="#000000"
android:textSize="12dp" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="#+id/tv_PublicHighestScore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textColor="#000000"
android:textSize="12dp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" points"
android:textColor="#000000"
android:textSize="8dp" />
</LinearLayout>
</TableRow>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="5dp" >
</LinearLayout>
<TextView
android:id="#+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#acacac"
android:text="Private"
android:textColor="#000000" />
<TableRow
android:id="#+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#acacac"
android:paddingTop="5dp" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="1.35"
android:text="Parties Thrown:"
android:textColor="#000000"
android:textSize="12dp" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="#+id/tv_PrivatePartyAmount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textColor="#000000"
android:textSize="12dp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" parties"
android:textColor="#000000"
android:textSize="8dp" />
</LinearLayout>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.35"
android:text="Average Score:"
android:textColor="#000000"
android:textSize="12dp" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="#+id/tv_PrivateAverageScore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textColor="#000000"
android:textSize="12dp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" points"
android:textColor="#000000"
android:textSize="8dp" />
</LinearLayout>
</TableRow>
<TableRow
android:id="#+id/tableRow5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#acacac"
android:paddingBottom="5dp"
android:paddingTop="5dp" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="1.35"
android:text="Biggest Party:"
android:textColor="#000000"
android:textSize="12dp" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="#+id/tv_PrivateBiggestParty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textColor="#000000"
android:textSize="12dp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" guests"
android:textColor="#000000"
android:textSize="8dp" />
</LinearLayout>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.35"
android:text="Highest Score:"
android:textColor="#000000"
android:textSize="12dp" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="#+id/tv_PrivateHighestScore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textColor="#000000"
android:textSize="12dp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" guests"
android:textColor="#000000"
android:textSize="8dp" />
</LinearLayout>
</TableRow>
</TableLayout>

Aligning columns in TableLayout

If i use this layout, everything is ok
See this Image:
<TableLayout android:id="#+id/TableLayout01" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#000000" android:layout_margin="10dip" android:padding="10dip" >
<TableRow android:id="#+id/row1" android:layout_width="wrap_content" android:layout_height="wrap_content" >
<TextView android:id="#+id/n1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ffffff" android:text="aaaaa a aaaaaaaaa:"></TextView>
<TextView android:id="#+id/c1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ffffff" android:layout_column="3" android:text="15"></TextView>
</TableRow>
<TableRow android:id="#+id/row2" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:id="#+id/n2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ffffff" android:text="aaaaaaa aaaaa:"></TextView>
<TextView android:id="#+id/c2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ffffff" android:layout_column="3" android:text="12"></TextView>
</TableRow>
<TableRow android:id="#+id/row3" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:id="#+id/n3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ffffff" android:text="aaa:"></TextView>
<TextView android:id="#+id/c3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ffffff" android:layout_column="3" android:text="14"></TextView>
</TableRow>
<TableRow android:id="#+id/row4" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:id="#+id/n4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ffffff" android:text="aaa:"></TextView>
<TextView android:id="#+id/c4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ffffff" android:layout_column="3" android:text="18"></TextView>
</TableRow>
<TableRow android:id="#+id/row5" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:id="#+id/n5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ffffff" android:text="aaaaaa aaaaaaaa:"></TextView>
<TextView android:id="#+id/c5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ffffff" android:layout_column="2" android:text="70"></TextView>
</TableRow>
</TableLayout>
But if i set android:layout_column="3" for the second textview in the last row, this shows http://www.lukafinzgar.com/nekul.png .
How should i set the attributes to get all the numbers in the third column?
You have to use "android:layout_width" and "android:layout_height" in TableLayout tag only. not anywhere else. And use "android:layout_weight" in each element of TableRow tag to adjust the columns horizontally.Try the below coding.
<TableLayout android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableRow>
<TextView android:id="#+id/cpotl1textview1"
android:layout_weight="0.5"
android:text="Total Outstanding" />
<EditText android:id="#+id/cpotl1edittext1"
android:layout_weight="0.5"
android:inputType="numberDecimal" />
</TableRow>
<TableRow>
<TextView android:id="#+id/cpotl1textview2"
android:layout_weight="0.5"
android:text="Claim Amount" />
<EditText android:id="#+id/cpotl1edittext2"
android:layout_weight="0.5"
android:inputType="numberDecimal" />
</TableRow>
<TableRow>
<TextView android:id="#+id/cpotl1textview3"
android:layout_weight="0.5"
android:text="Select Message" />
<AutoCompleteTextView android:id="#+id/cpotl1autocompletetextview"
android:layout_weight="0.5"
android:hint="Templates" />
</TableRow>
</TableLayout>
Thanks for opportunity.
Try This:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/TableLayout01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10dip"
android:background="#000000"
android:padding="10dip" >
<TableRow
android:id="#+id/row1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/n1"
android:layout_width="wrap_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="aaaaa a aaaaaaaaa:"
android:textColor="#ffffff" >
</TextView>
<TextView
android:id="#+id/c1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="3"
android:text="15"
android:textColor="#ffffff" >
</TextView>
</TableRow>
<TableRow
android:id="#+id/row2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/n2"
android:layout_width="wrap_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="aaaaaaa aaaaa:"
android:textColor="#ffffff" >
</TextView>
<TextView
android:id="#+id/c2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="3"
android:text="12"
android:textColor="#ffffff" >
</TextView>
</TableRow>
<TableRow
android:id="#+id/row3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/n3"
android:layout_width="wrap_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="aaa:"
android:textColor="#ffffff" >
</TextView>
<TextView
android:id="#+id/c3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="3"
android:text="14"
android:textColor="#ffffff" >
</TextView>
</TableRow>
<TableRow
android:id="#+id/row4"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/n4"
android:layout_width="wrap_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="aaa:"
android:textColor="#ffffff" >
</TextView>
<TextView
android:id="#+id/c4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="3"
android:text="18"
android:textColor="#ffffff" >
</TextView>
</TableRow>
<TableRow
android:id="#+id/row5"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/n5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="aaaaaa aaarrrrrrraaaaa:"
android:textColor="#ffffff" >
</TextView>
<TextView
android:id="#+id/c5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="3"
android:text="70"
android:textColor="#ffffff" >
</TextView>
</TableRow>
</TableLayout>

Categories

Resources