How to increase width of particular EditText in Table Raw (Table layout) - android

I am using Table Layout.
Here i have three EditText's with same width ="200dp".
But i want to increase the size of 3rd EditText.
I made its width="wrap_content" but all other EditText also getting "wrap_content"
How can i increase the width of 3rd EditText with out affecting other EditText's.
This code for 3rd EditText:-
<TableRow
android:gravity="center_horizontal"
android:layout_marginBottom="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:id="#+id/addl"
android:text="Address"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:id="#+id/colon"
android:text=":" />
<EditText
android:layout_width="250dp"
android:layout_marginLeft="20dp"
android:id="#+id/et"
android:singleLine="true"/>
</TableRow>
Now i want to increase width of Address EditText only

i think you can achieve this by layout_weight parameter of EditTexts like below
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/relativeLayout12"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#909090"
android:padding="10dp" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Student ID"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text=":"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="6" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text=":"
android:textColor="#000000" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Class"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text=":"
android:textColor="#000000" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Address"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text=":"
android:textColor="#000000" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
</TableRow>
</TableLayout>
EDIT
This is the outcome

put the property android:stretchColumns="2" in TableLayout
<TableLayout android:stretchColumns="2" ... > .... </TableLayout>

Related

TableLayout doesn't fit the screen

I am a beginner and I have designed a layout that displays the rows from the XML upon the click of a "show" Button.
But when I don't click the show button, I want the table row with id-blank to increase its height to fit the screen.
Please suggest a way to do that.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<!-- Row 1 with single column -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/White"
android:gravity="center_horizontal"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="Sale Report"
android:textSize="15sp"
android:textStyle="bold" />
</LinearLayout>
<!-- Row 2 with 3 columns -->
<LinearLayout
android:id="#+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="#drawable/borders"
android:gravity="center"
android:orientation="horizontal"
android:paddingBottom="5dp"
android:paddingTop="5dp" >
<EditText
android:id="#+id/starttime"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:inputType="none"
android:textSize="#dimen/textSize" />
<EditText
android:id="#+id/stoptime"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:inputType="none"
android:textSize="#dimen/textSize" />
<Button
android:id="#+id/show"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight=".75"
android:text="show" />
<Button
android:id="#+id/back"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight=".75"
android:text="back" />
</LinearLayout>
<!-- Row 3 with 2 columns -->
<TableLayout
android:id="#+id/sale_table_data"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="5dp"
android:background="#drawable/borders"
android:gravity="center" >
<TableRow
android:id="#+id/sale_report_header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/Yellow" >
<TextView
android:id="#+id/particulars"
android:layout_weight="2"
android:gravity="center_horizontal"
android:text="Particulars"
android:textStyle="bold" />
<TextView
android:id="#+id/voucherNo"
android:layout_weight="1"
android:gravity="fill_horizontal"
android:text="VCH No"
android:textStyle="bold" />
<TextView
android:id="#+id/quantity"
android:layout_weight="1"
android:gravity="fill_horizontal"
android:text="Quantity"
android:textStyle="bold" />
<TextView
android:id="#+id/amount"
android:layout_weight="2"
android:gravity="center_horizontal"
android:text="Amount"
android:textStyle="bold" />
<TextView
android:id="#+id/date"
android:layout_weight="1.3"
android:gravity="center_horizontal"
android:text="Date"
android:textStyle="bold" />
</TableRow>
<TableRow
android:id="#+id/blank"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="3" >
<TextView
android:id="#+id/blank9"
android:layout_weight="2"
android:gravity="center_horizontal"
android:text="Particulars"
android:textStyle="bold" />
<TextView
android:id="#+id/blank10"
android:layout_weight="1"
android:gravity="fill_horizontal"
android:text="VCH No"
android:textStyle="bold" />
<TextView
android:id="#+id/blank11"
android:layout_weight="1"
android:gravity="fill_horizontal"
android:text="Quantity"
android:textStyle="bold" />
<TextView
android:id="#+id/blank12"
android:layout_weight="2"
android:gravity="center_horizontal"
android:text="Amount"
android:textStyle="bold" />
<TextView
android:id="#+id/blank13"
android:layout_weight="1.3"
android:gravity="center_horizontal"
android:text="Date"
android:textStyle="bold" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/no_borders" >
<TextView
android:id="#+id/blank1"
android:layout_weight="1"
android:gravity="center_horizontal"
android:textStyle="bold" />
<TextView
android:id="#+id/blank2"
android:layout_weight="1"
android:gravity="center_horizontal"
android:textStyle="bold" />
<TextView
android:id="#+id/Total"
android:layout_weight="1"
android:gravity="center"
android:text="Total"
android:textStyle="bold" />
<TextView
android:id="#+id/total_sales"
android:layout_weight="2"
android:gravity="center_horizontal"
android:text="Amount_value"
android:textStyle="bold" />
<TextView
android:id="#+id/blank3"
android:layout_weight="1"
android:gravity="center_horizontal"
android:textStyle="bold" />
</TableRow>
</TableLayout>
</LinearLayout>
</HorizontalScrollView>
</ScrollView>

Table layout column spacing

I am trying to format my tablelayout but I dont seem to get things working quite well.
I have 4 columns that I need them spaced as nice as possible. I was thinking really having 3 columns with same width and the last column taking the rest of the space. The last column is ok to wrap around in 2 or more lines but the first 3 columns has to be single line and NOT truncated. Here is my code
<TableLayout android:id="#+id/tlMylayout" android:layout_width="fill_parent" android:layout_height="wrap_content"
android:stretchColumns="*" android:shrinkColumns="*" >
<TableRow android:layout_width="fill_parent" android:layout_height="wrap_content">
<TextView android:gravity="center" android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content" style="#style/showtext_style" android:text="col1" />
<TextView android:gravity="center" android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content" style="#style/showtext_style" android:text="col2" />
<TextView android:gravity="center" android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content" style="#style/showtext_style" android:text="col3" />
<TextView android:gravity="center" android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content" style="#style/showtext_style" android:text="lastCol" />
</TableRow>
<TableRow android:layout_width="fill_parent" android:layout_height="wrap_content">
<TextView android:gravity="center" android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content"android:text="2011-01-01 14:59" />
<TextView android:gravity="center" android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:text="50" />
<TextView android:gravity="center" android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:text="0.57" />
<TextView android:gravity="center" android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="this is the last one and can be very long string if I want it to be" />
</TableRow>
</TableLayout>
Try
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/tlMylayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:shrinkColumns="*"
android:stretchColumns="*" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="0"
android:layout_height="wrap_content"
android:layout_weight=".25"
android:gravity="center"
android:text="col1" />
<TextView
android:layout_width="0"
android:layout_height="wrap_content"
android:layout_weight=".25"
android:gravity="center"
android:text="col2" />
<TextView
android:layout_width="0"
android:layout_height="wrap_content"
android:layout_weight=".25"
android:gravity="center"
android:text="col3" />
<TextView
android:layout_width="0"
android:layout_height="wrap_content"
android:layout_weight=".25"
android:gravity="center"
android:text="lastCol" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="0"
android:layout_height="wrap_content"
android:layout_weight=".25"
android:gravity="center"
android:text="2011-01-01 14:59" />
<TextView
android:layout_width="0"
android:layout_height="wrap_content"
android:layout_weight=".25"
android:gravity="center"
android:singleLine="true"
android:text="50" />
<TextView
android:layout_width="0"
android:layout_height="wrap_content"
android:layout_weight=".25"
android:gravity="center"
android:singleLine="true"
android:text="0.57" />
<TextView
android:layout_width="0"
android:layout_height="wrap_content"
android:layout_weight=".25"
android:gravity="center"
android:text="this is the last one and can be very long string if I want it to be" />
</TableRow>
I removed layout_gravity and added layout_weight to TextView

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

doesnt set text value in android

Im new in andorid.I put textview to set data from mymethods.But it goes force close.But I tried it in another activity page my code worked.So ı suspected my xml layout .does anyone take care of this problem ,if so I will be very gratefull.Thanks Here are my layout.xml and my codes:
String iskate=WorkCat.Kategori(Workid);
iskat.setText(iskate);
Log.d("işkategorisi",iskate);
and Log.cat shows true value.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/backgrund" >
<!-- Header Starts -->
<LinearLayout
android:id="#+id/header"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:layout_alignParentTop="true"
android:background="#layout/header" >
</LinearLayout>
<!-- Header Ends -->
<!-- Footer Start -->
<LinearLayout
android:id="#+id/footer"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:layout_alignParentBottom="true"
android:background="#layout/footer" >
<ImageView
android:id="#+id/imagegeri"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="220dp"
android:src="#drawable/geri" />
<ImageView
android:id="#+id/imagecikis"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#drawable/cikis" />
</LinearLayout>
<TextView
android:id="#+id/textAD"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/header"
android:layout_alignParentRight="true"
android:layout_marginBottom="14dp"
android:layout_marginRight="26dp"
android:text="Small Text"
android:textSize="13dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF" />
<LinearLayout
android:id="#+id/content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#id/footer"
android:layout_below="#id/textAD" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="#id/header"
android:orientation="vertical"
android:padding="10dip" >
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TableRow>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="İş Kategorisi"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000"
android:textStyle="bold" />
<TextView
android:id="#+id/txtiskate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="rfyr"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000"
android:textStyle="bold" />
</TableRow>
<TableRow>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Aşama"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000"
android:textStyle="bold" />
<Spinner
android:id="#+id/spinner2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true" >
</Spinner>
</TableRow>
<TableRow>
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Görevli"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000"
android:textStyle="bold" />
<AutoCompleteTextView
android:id="#+id/Searchname"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</AutoCompleteTextView>
</TableRow>
<TableRow>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Öncelik"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000"
android:textStyle="bold" />
<Spinner
android:id="#+id/spinner3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true" >
</Spinner>
</TableRow>
<EditText
android:id="#+id/edituacikla"
android:layout_width="290dp"
android:layout_height="140dp"
android:ems="10"
android:inputType="textMultiLine" />
<TableRow>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Gerçekleşen Süre"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000"
android:textStyle="bold" />
<EditText
android:id="#+id/edittoplm"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView6"
android:layout_alignBottom="#+id/textView6"
android:layout_alignLeft="#+id/spinner4"
android:ems="10"/>
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Saat"
android:textAppearance="?android:attr/textAppearanceSmall" />
</TableRow>
<TableRow>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tamamlanan(%)"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000"
android:textStyle="bold" />
<Spinner
android:id="#+id/spinner5"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_alignParentLeft="true" >
</Spinner>
</TableRow>
<TableRow>
<Button
android:id="#+id/btnvzgec"
style="?android:attr/buttonStyleSmall"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="Vazgec" />
<Button
android:id="#+id/uwgncelle"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Güncelle" />
</TableRow>
</TableLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
</RelativeLayout>
Initialize your Text View first
TextView iskat = (TextView)findViewById(R.id.txtiskate);
String iskate=WorkCat.Kategori(Workid);
iskat.setText(iskate);
First you need to initialize your textview then after you can use it. Try below code.
TextView iskat = (TextView)findViewById(R.id.txtiskate);
String iskate=WorkCat.Kategori(Workid);
iskat.setText(iskate);
'iskate' should be instance of a 'TextView' like iskate=(TextView)(TextView)findViewById(id of the layout in xml here);
in your case its a string how is this possible this will show compile time error.

Categories

Resources