<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_weight="1"
android:text="MARKETING SUPERVISOR"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="CHALLAN"
android:gravity="center"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_weight="1"
android:text="Perm.IncmTax Num."
android:gravity="center"/>
<EditText
android:id="#+id/editText1"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="fill_parent"
android:inputType="number"
android:gravity="center" >
<requestFocus />
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView2"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="Customer Code Number"
android:textAppearance="?android:attr/textAppearanceMedium"
android:gravity="center"/>
<EditText
android:id="#+id/editText2"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="fill_parent"
android:inputType="number"
android:gravity="center">
<requestFocus />
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView3"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="Customer Name"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText3"
android:gravity="center"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:inputType="textPersonName" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView4"
android:gravity="center"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Customer Address"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText4"
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:inputType="textPostalAddress" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView5"
android:gravity="center"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Name of Cosignee"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText5"
android:layout_width="fill_parent"
android:gravity="center"
android:layout_weight="1"
android:layout_height="fill_parent"
android:inputType="textPersonName" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView6"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="fill_parent"
android:gravity="center"
android:text="Address of Cosignee"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText6"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:inputType="textPostalAddress" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView7"
android:gravity="center"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Sales Order"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText7"
android:layout_width="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:layout_height="fill_parent"
android:inputType="number" >
<requestFocus />
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView8"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Customer Order Date"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText8"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:inputType="date" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="INVOICE DETAILS"
android:gravity="center"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="fill_parent"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Invoice Number"
android:gravity="center"/>
<EditText
android:id="#+id/editText1"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="wrap_content"
android:inputType="number" >
<requestFocus />
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView2"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="fill_parent"
android:gravity="center"
android:text="Date of issue of Invoice"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText8"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:inputType="date" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView3"
android:layout_width="fill_parent"
android:gravity="center"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="Time of Issue of Invoice"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText3"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="fill_parent"
android:gravity="center"
android:inputType="textPersonName" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView4"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Date of Dispatch of Goods"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText8"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:inputType="date" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView5"
android:layout_width="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:layout_height="fill_parent"
android:text="Time of Dispatch of Goods"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText5"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="fill_parent"
android:gravity="center"
android:inputType="textPersonName" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView6"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="fill_parent"
android:gravity="center"
android:text="Description of Goods"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText6"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="fill_parent"
android:gravity="center"
android:inputType="textPostalAddress" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView7"
android:layout_weight="1"
android:layout_width="fill_parent"
android:gravity="center"
android:layout_height="fill_parent"
android:text="Quantity Total"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText7"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:layout_weight="1"
android:inputType="number" >
<requestFocus />
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView8"
android:layout_width="fill_parent"
android:gravity="center"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="Unit"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText8"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:inputType="date" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView8"
android:layout_width="fill_parent"
android:gravity="center"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="Total Amount"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText8"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:inputType="date" />
</LinearLayout>
<LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
I am getting the "Force Close" on the execution of xml code.
The error log is giving errors like:
1)TextView cannot be cast to android.view.ViewGroup
2)Unable to update index for central
and some many more weird ones
You have to give different id's to your texViews try this:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_weight="1"
android:text="MARKETING SUPERVISOR"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/textView2"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="CHALLAN"
android:gravity="center"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_weight="1"
android:text="Perm.IncmTax Num."
android:gravity="center"/>
<EditText
android:id="#+id/editText1"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="fill_parent"
android:inputType="number"
android:gravity="center" >
<requestFocus />
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView4"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="Customer Code Number"
android:textAppearance="?android:attr/textAppearanceMedium"
android:gravity="center"/>
<EditText
android:id="#+id/editText2"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="fill_parent"
android:inputType="number"
android:gravity="center">
<requestFocus />
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView5"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="Customer Name"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText3"
android:gravity="center"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:inputType="textPersonName" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView6"
android:gravity="center"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Customer Address"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText4"
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:inputType="textPostalAddress" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView7"
android:gravity="center"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Name of Cosignee"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText5"
android:layout_width="fill_parent"
android:gravity="center"
android:layout_weight="1"
android:layout_height="fill_parent"
android:inputType="textPersonName" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView8"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="fill_parent"
android:gravity="center"
android:text="Address of Cosignee"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText6"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:inputType="textPostalAddress" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView9"
android:gravity="center"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Sales Order"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText7"
android:layout_width="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:layout_height="fill_parent"
android:inputType="number" >
<requestFocus />
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView10"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Customer Order Date"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText8"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:inputType="date" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/textView11"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="INVOICE DETAILS"
android:gravity="center"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="#+id/textView12"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="fill_parent"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Invoice Number"
android:gravity="center"/>
<EditText
android:id="#+id/editText13"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="wrap_content"
android:inputType="number" >
<requestFocus />
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView14"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="fill_parent"
android:gravity="center"
android:text="Date of issue of Invoice"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText15"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:inputType="date" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView16"
android:layout_width="fill_parent"
android:gravity="center"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="Time of Issue of Invoice"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText17"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="fill_parent"
android:gravity="center"
android:inputType="textPersonName" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView18"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Date of Dispatch of Goods"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText19"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:inputType="date" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView20"
android:layout_width="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:layout_height="fill_parent"
android:text="Time of Dispatch of Goods"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText21"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="fill_parent"
android:gravity="center"
android:inputType="textPersonName" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView22"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="fill_parent"
android:gravity="center"
android:text="Description of Goods"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText23"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="fill_parent"
android:gravity="center"
android:inputType="textPostalAddress" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView24"
android:layout_weight="1"
android:layout_width="fill_parent"
android:gravity="center"
android:layout_height="fill_parent"
android:text="Quantity Total"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText25"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:layout_weight="1"
android:inputType="number" >
<requestFocus />
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView26"
android:layout_width="fill_parent"
android:gravity="center"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="Unit"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText27"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:inputType="date" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView28"
android:layout_width="fill_parent"
android:gravity="center"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="Total Amount"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText29"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:inputType="date" />
</LinearLayout>
</LinearLayout>
</ScrollView>
Hope that helps.
Related
When I have an application filled with text, when I scroll down to see the end of the text, it must show me a background at the end .. I wrote this but it shows the background in the middle - I think
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/bglow"
android:layout_alignParentBottom="true"
android:layout_marginBottom="0dip"
android:gravity="bottom" />
How can I put a background at the end?
Edited
<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:background="#FFFFFF"
android:gravity="center" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/bglow"
android:layout_alignParentBottom="true"
android:layout_marginBottom="0dip"
android:gravity="bottom" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:gravity="center"
android:orientation="vertical"
android:textStyle="italic" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:text=""
android:textSize="7sp" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:src="#drawable/1" />
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:text=""
android:textSize="15sp" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:src="#drawable/logoline" />
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:text=""
android:textSize="5sp" />
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:gravity="center_vertical"
android:orientation="horizontal"
android:textStyle="italic"
android:weightSum="100" >
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="60"
android:gravity="center"
android:src="#drawable/2" />
<Button
android:id="#+id/h"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="40"
android:background="#drawable/buttoncolor"
android:gravity="left"
android:text="H"
android:textColor="#AD9C64"
android:textSize="25sp"
android:textStyle="italic"
android:typeface="serif" />
</LinearLayout>
</ScrollView>
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:text=""
android:textSize="15sp" />
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:gravity="center_vertical"
android:orientation="horizontal"
android:textStyle="italic"
android:weightSum="100" >
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="60"
android:gravity="center"
android:src="#drawable/3" />
<Button
android:id="#+id/r"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="40"
android:background="#drawable/buttoncolor"
android:gravity="left"
android:text="R"
android:textColor="#AD9C64"
android:textSize="25sp"
android:textStyle="italic"
android:typeface="serif" />
</LinearLayout>
</ScrollView>
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:text=""
android:textSize="15sp" />
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:gravity="center_vertical"
android:orientation="horizontal"
android:textStyle="italic"
android:weightSum="100" >
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="60"
android:gravity="center"
android:src="#drawable/4" />
<Button
android:id="#+id/4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="40"
android:background="#drawable/buttoncolor"
android:gravity="left"
android:text="D"
android:textColor="#AD9C64"
android:textSize="22sp"
android:textStyle="italic"
android:typeface="serif" />
</LinearLayout>
</ScrollView>
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:text=""
android:textSize="7sp" />
<Button
android:id="#+id/ab"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/buttoncolor"
android:gravity="center"
android:text="About"
android:textColor="#AD9C64"
android:textSize="10sp"
android:textStyle="italic"
android:typeface="serif" />
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:text=""
android:textSize="7sp" />
</LinearLayout>
</ScrollView>
</LinearLayout>
</RelativeLayout>
In my project header is fix in top of the screen.
when i click on edit text the virtual keyboard is open that time header is scroll up and not visible in screen.
how to fix it in my screen.
please give me suggestion.
Thank You.
My code is below:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:id="#+id/header_one"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#drawable/header"
android:isScrollContainer="true"
android:orientation="vertical" >
<com.esp.leadtransit.uc.Header
android:id="#+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/header_one"
android:background="#ffffff"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="5dp"
android:weightSum="10" >
<com.esp.leadtransit.uc.EspTextView
style="#style/TextRegularBlack"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="10"
android:gravity="right"
android:tag="100"
android:text="New Lead Entry"
android:textColor="#3a4e6c"
android:textSize="20sp"
android:textStyle="bold" />
<com.esp.leadtransit.uc.EspTextView
android:id="#+id/txt_time"
style="#style/TextRegularBlack"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="3"
android:gravity="center"
android:tag="200" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:weightSum="10" >
<com.esp.leadtransit.uc.EspTextView
style="#style/TextRegularWhite"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="6"
android:gravity="right"
android:tag="200"
android:text="City:" />
<com.esp.leadtransit.uc.EspEditText
android:id="#+id/et_city"
style="#style/TextRegularBlack"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="4"
android:background="#drawable/rowbg"
android:gravity="left"
android:hint="City"
android:imeOptions="actionNext"
android:maxLength="35"
android:nextFocusDown="#+id/et_state"
android:singleLine="true"
android:tag="200" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:weightSum="10" >
<com.esp.leadtransit.uc.EspTextView
style="#style/TextRegularWhite"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="6"
android:gravity="right"
android:tag="200"
android:text="State:" />
<AutoCompleteTextView
android:id="#+id/et_state"
style="#style/TextRegularBlack"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="4"
android:background="#drawable/rowbg"
android:dropDownHeight="200dp"
android:editable="false"
android:gravity="left"
android:hint="State"
android:imeOptions="actionNext"
android:maxLength="2"
android:nextFocusDown="#+id/et_zip"
android:singleLine="true"
android:tag="200" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:weightSum="10" >
<com.esp.leadtransit.uc.EspTextView
style="#style/TextRegularWhite"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="6"
android:gravity="right"
android:tag="200"
android:text="Zip:" />
<com.esp.leadtransit.uc.EspEditText
android:id="#+id/et_zip"
style="#style/TextRegularBlack"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="4"
android:background="#drawable/rowbg"
android:gravity="left"
android:hint="11742"
android:inputType="number"
android:maxLength="7"
android:singleLine="true"
android:tag="200" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/ll_optional"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="#ffffff"
android:orientation="vertical" >
<com.esp.leadtransit.uc.EspTextView
style="#style/TextRegularGray"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_weight="7"
android:gravity="center_horizontal"
android:tag="200"
android:text="Optional Items"
android:visibility="gone" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:weightSum="10" >
<com.esp.leadtransit.uc.EspTextView
style="#style/TextRegularWhite"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="6"
android:gravity="right"
android:tag="200"
android:text="Phone 1:" />
<com.esp.leadtransit.uc.EspEditText
android:id="#+id/et_phone_one"
style="#style/TextRegularBlack"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="4"
android:background="#drawable/rowbg"
android:gravity="left"
android:hint="(999) 555-1212"
android:imeOptions="actionNext"
android:inputType="phone"
android:maxLength="15"
android:nextFocusDown="#+id/et_phone_two"
android:singleLine="true"
android:tag="200" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:weightSum="10" >
<com.esp.leadtransit.uc.EspTextView
style="#style/TextRegularWhite"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="6"
android:gravity="right"
android:tag="200"
android:text="Phone 2:" />
<com.esp.leadtransit.uc.EspEditText
android:id="#+id/et_phone_two"
style="#style/TextRegularBlack"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="4"
android:background="#drawable/rowbg"
android:gravity="left"
android:hint="(999) 555-1212"
android:imeOptions="actionNext"
android:inputType="phone"
android:maxLength="15"
android:nextFocusDown="#+id/et_email"
android:singleLine="true"
android:tag="200" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:weightSum="10" >
<com.esp.leadtransit.uc.EspTextView
style="#style/TextRegularWhite"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="6"
android:gravity="right"
android:tag="200"
android:text="Email:" />
<com.esp.leadtransit.uc.EspEditText
android:id="#+id/et_email"
style="#style/TextRegularBlack"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="4"
android:background="#drawable/rowbg"
android:gravity="left"
android:hint="Email"
android:imeOptions="actionNext"
android:inputType="textEmailAddress"
android:maxLength="100"
android:nextFocusDown="#+id/et_date"
android:singleLine="true"
android:tag="200" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_product"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:padding="10dp"
android:weightSum="10" >
<com.esp.leadtransit.uc.EspTextView
style="#style/TextRegularWhite"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="6"
android:gravity="right"
android:tag="200"
android:text="Product Interest:" />
<AutoCompleteTextView
android:id="#+id/ll_product_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="4"
android:background="#drawable/rowbg"
android:editable="false"
android:gravity="left"
android:maxLength="50"
android:padding="10dp" >
</AutoCompleteTextView>
</LinearLayout>
<LinearLayout
android:id="#+id/ll_alt_one"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:weightSum="10" >
<com.esp.leadtransit.uc.EspTextView
style="#style/TextRegularWhite"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="6"
android:gravity="right"
android:tag="200"
android:text="Alt 1:" />
<com.esp.leadtransit.uc.EspEditText
android:id="#+id/et_alt_one"
style="#style/TextRegularBlack"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="4"
android:background="#drawable/rowbg"
android:gravity="left"
android:maxLength="50"
android:singleLine="true"
android:tag="200" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_alt_two"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:weightSum="10" >
<com.esp.leadtransit.uc.EspTextView
style="#style/TextRegularWhite"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="6"
android:gravity="right"
android:tag="200"
android:text="Alt 2:" />
<com.esp.leadtransit.uc.EspEditText
android:id="#+id/et_alt_two"
style="#style/TextRegularBlack"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="4"
android:background="#drawable/rowbg"
android:gravity="left"
android:maxLength="50"
android:singleLine="true"
android:tag="200" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_date"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="10dp"
android:weightSum="10" >
<com.esp.leadtransit.uc.EspTextView
android:id="#+id/txtDateLabel"
style="#style/TextRegularWhite"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_weight="6"
android:gravity="right"
android:tag="200"
android:text="Date:" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/txtDateLabel"
android:layout_weight="4"
android:background="#drawable/rowbg"
android:gravity="center" >
<com.esp.leadtransit.uc.EspTextView
android:id="#+id/et_date"
style="#style/TextRegularBlack"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:layout_toLeftOf="#+id/iv_date"
android:gravity="left"
android:hint="Date"
android:imeOptions="actionNext"
android:nextFocusDown="#+id/et_time"
android:paddingRight="1dp"
android:singleLine="true"
android:tag="200" />
<ImageView
android:id="#+id/iv_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="#drawable/close"
android:padding="15dp" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/ll_time"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="10dp"
android:weightSum="10" >
<com.esp.leadtransit.uc.EspTextView
android:id="#+id/txttimeLabel"
style="#style/TextRegularWhite"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_weight="6"
android:gravity="right"
android:tag="200"
android:text="Time:" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/txttimeLabel"
android:layout_weight="4"
android:background="#drawable/rowbg"
android:gravity="center" >
<com.esp.leadtransit.uc.EspTextView
android:id="#+id/et_time"
style="#style/TextRegularBlack"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:layout_toLeftOf="#+id/iv_time"
android:gravity="left"
android:hint="Time"
android:imeOptions="actionNext"
android:nextFocusDown="#+id/et_time"
android:paddingRight="1dp"
android:singleLine="true"
android:tag="200" />
<ImageView
android:id="#+id/iv_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="#drawable/close"
android:padding="15dp" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:weightSum="10" >
<com.esp.leadtransit.uc.EspTextView
style="#style/TextRegularWhite"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="6"
android:gravity="right"
android:tag="200"
android:text="Comments / Notes:" />
<com.esp.leadtransit.uc.EspEditText
android:id="#+id/et_comments"
style="#style/TextRegularBlack"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="4"
android:background="#drawable/rowbg"
android:gravity="top|left"
android:lines="4"
android:maxLength="2000"
android:tag="200" />
</LinearLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp" >
<com.esp.leadtransit.uc.EspTextView
android:id="#+id/tv_waiver"
style="#style/TextRegularWhite_other"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:tag="200"
android:text="DNC Waiver:" />
<ToggleButton
android:id="#+id/tbtn_dnc_waiver"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/tv_waiver"
android:background="#drawable/toggle_button"
android:textOff=""
android:textOn="" />
</RelativeLayout>
<LinearLayout
android:id="#+id/ll_attachment"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="#ffffff"
android:orientation="vertical" >
<Button
android:id="#+id/btn_submit"
style="#style/TextRegularBlack"
android:layout_width="120dp"
android:layout_height="40dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:background="#drawable/selector_menu_btn_orange"
android:tag="200"
android:text="Submit"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</ScrollView>
in Manifest not set any windowSoftInputMode.
Simply keep your header part out of scroll view ..
Firstly use Relative OR Linear layout as your first container .. then after keep your Header layout .. and then user scroll view for rest of your layout ..
That's it .. you are good to go ..
For Ex:--
<?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:orientation="vertical"
>
// Then your header view starts ..
// Then your header view ends ..
// Your scroll view starts ..
// your child layout starts
// your child layout ends
// Your scroll view ends ..
</LinearLayout>
Do it like this
<?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:fillViewport="true" >
<LinearLayout
android:id="#+id/header_one"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#drawable/header"
android:isScrollContainer="true"
android:orientation="vertical" >
<com.esp.leadtransit.uc.Header
android:id="#+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/header_one"
android:background="#ffffff"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="5dp"
android:weightSum="10" >
<com.esp.leadtransit.uc.EspTextView
style="#style/TextRegularBlack"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="10"
android:gravity="right"
android:tag="100"
android:text="New Lead Entry"
android:textColor="#3a4e6c"
android:textSize="20sp"
android:textStyle="bold" />
<com.esp.leadtransit.uc.EspTextView
android:id="#+id/txt_time"
style="#style/TextRegularBlack"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="3"
android:gravity="center"
android:tag="200" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:weightSum="10" >
<com.esp.leadtransit.uc.EspTextView
style="#style/TextRegularWhite"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="6"
android:gravity="right"
android:tag="200"
android:text="City:" />
<com.esp.leadtransit.uc.EspEditText
android:id="#+id/et_city"
style="#style/TextRegularBlack"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="4"
android:background="#drawable/rowbg"
android:gravity="left"
android:hint="City"
android:imeOptions="actionNext"
android:maxLength="35"
android:nextFocusDown="#+id/et_state"
android:singleLine="true"
android:tag="200" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:weightSum="10" >
<com.esp.leadtransit.uc.EspTextView
style="#style/TextRegularWhite"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="6"
android:gravity="right"
android:tag="200"
android:text="State:" />
<AutoCompleteTextView
android:id="#+id/et_state"
style="#style/TextRegularBlack"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="4"
android:background="#drawable/rowbg"
android:dropDownHeight="200dp"
android:editable="false"
android:gravity="left"
android:hint="State"
android:imeOptions="actionNext"
android:maxLength="2"
android:nextFocusDown="#+id/et_zip"
android:singleLine="true"
android:tag="200" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:weightSum="10" >
<com.esp.leadtransit.uc.EspTextView
style="#style/TextRegularWhite"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="6"
android:gravity="right"
android:tag="200"
android:text="Zip:" />
<com.esp.leadtransit.uc.EspEditText
android:id="#+id/et_zip"
style="#style/TextRegularBlack"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="4"
android:background="#drawable/rowbg"
android:gravity="left"
android:hint="11742"
android:inputType="number"
android:maxLength="7"
android:singleLine="true"
android:tag="200" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/ll_optional"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="#ffffff"
android:orientation="vertical" >
<com.esp.leadtransit.uc.EspTextView
style="#style/TextRegularGray"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_weight="7"
android:gravity="center_horizontal"
android:tag="200"
android:text="Optional Items"
android:visibility="gone" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:weightSum="10" >
<com.esp.leadtransit.uc.EspTextView
style="#style/TextRegularWhite"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="6"
android:gravity="right"
android:tag="200"
android:text="Phone 1:" />
<com.esp.leadtransit.uc.EspEditText
android:id="#+id/et_phone_one"
style="#style/TextRegularBlack"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="4"
android:background="#drawable/rowbg"
android:gravity="left"
android:hint="(999) 555-1212"
android:imeOptions="actionNext"
android:inputType="phone"
android:maxLength="15"
android:nextFocusDown="#+id/et_phone_two"
android:singleLine="true"
android:tag="200" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:weightSum="10" >
<com.esp.leadtransit.uc.EspTextView
style="#style/TextRegularWhite"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="6"
android:gravity="right"
android:tag="200"
android:text="Phone 2:" />
<com.esp.leadtransit.uc.EspEditText
android:id="#+id/et_phone_two"
style="#style/TextRegularBlack"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="4"
android:background="#drawable/rowbg"
android:gravity="left"
android:hint="(999) 555-1212"
android:imeOptions="actionNext"
android:inputType="phone"
android:maxLength="15"
android:nextFocusDown="#+id/et_email"
android:singleLine="true"
android:tag="200" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:weightSum="10" >
<com.esp.leadtransit.uc.EspTextView
style="#style/TextRegularWhite"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="6"
android:gravity="right"
android:tag="200"
android:text="Email:" />
<com.esp.leadtransit.uc.EspEditText
android:id="#+id/et_email"
style="#style/TextRegularBlack"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="4"
android:background="#drawable/rowbg"
android:gravity="left"
android:hint="Email"
android:imeOptions="actionNext"
android:inputType="textEmailAddress"
android:maxLength="100"
android:nextFocusDown="#+id/et_date"
android:singleLine="true"
android:tag="200" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_product"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:padding="10dp"
android:weightSum="10" >
<com.esp.leadtransit.uc.EspTextView
style="#style/TextRegularWhite"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="6"
android:gravity="right"
android:tag="200"
android:text="Product Interest:" />
<AutoCompleteTextView
android:id="#+id/ll_product_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="4"
android:background="#drawable/rowbg"
android:editable="false"
android:gravity="left"
android:maxLength="50"
android:padding="10dp" >
</AutoCompleteTextView>
</LinearLayout>
<LinearLayout
android:id="#+id/ll_alt_one"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:weightSum="10" >
<com.esp.leadtransit.uc.EspTextView
style="#style/TextRegularWhite"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="6"
android:gravity="right"
android:tag="200"
android:text="Alt 1:" />
<com.esp.leadtransit.uc.EspEditText
android:id="#+id/et_alt_one"
style="#style/TextRegularBlack"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="4"
android:background="#drawable/rowbg"
android:gravity="left"
android:maxLength="50"
android:singleLine="true"
android:tag="200" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_alt_two"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:weightSum="10" >
<com.esp.leadtransit.uc.EspTextView
style="#style/TextRegularWhite"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="6"
android:gravity="right"
android:tag="200"
android:text="Alt 2:" />
<com.esp.leadtransit.uc.EspEditText
android:id="#+id/et_alt_two"
style="#style/TextRegularBlack"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="4"
android:background="#drawable/rowbg"
android:gravity="left"
android:maxLength="50"
android:singleLine="true"
android:tag="200" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_date"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="10dp"
android:weightSum="10" >
<com.esp.leadtransit.uc.EspTextView
android:id="#+id/txtDateLabel"
style="#style/TextRegularWhite"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_weight="6"
android:gravity="right"
android:tag="200"
android:text="Date:" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/txtDateLabel"
android:layout_weight="4"
android:background="#drawable/rowbg"
android:gravity="center" >
<com.esp.leadtransit.uc.EspTextView
android:id="#+id/et_date"
style="#style/TextRegularBlack"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:layout_toLeftOf="#+id/iv_date"
android:gravity="left"
android:hint="Date"
android:imeOptions="actionNext"
android:nextFocusDown="#+id/et_time"
android:paddingRight="1dp"
android:singleLine="true"
android:tag="200" />
<ImageView
android:id="#+id/iv_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="#drawable/close"
android:padding="15dp" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/ll_time"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="10dp"
android:weightSum="10" >
<com.esp.leadtransit.uc.EspTextView
android:id="#+id/txttimeLabel"
style="#style/TextRegularWhite"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_weight="6"
android:gravity="right"
android:tag="200"
android:text="Time:" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/txttimeLabel"
android:layout_weight="4"
android:background="#drawable/rowbg"
android:gravity="center" >
<com.esp.leadtransit.uc.EspTextView
android:id="#+id/et_time"
style="#style/TextRegularBlack"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:layout_toLeftOf="#+id/iv_time"
android:gravity="left"
android:hint="Time"
android:imeOptions="actionNext"
android:nextFocusDown="#+id/et_time"
android:paddingRight="1dp"
android:singleLine="true"
android:tag="200" />
<ImageView
android:id="#+id/iv_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="#drawable/close"
android:padding="15dp" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:weightSum="10" >
<com.esp.leadtransit.uc.EspTextView
style="#style/TextRegularWhite"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="6"
android:gravity="right"
android:tag="200"
android:text="Comments / Notes:" />
<com.esp.leadtransit.uc.EspEditText
android:id="#+id/et_comments"
style="#style/TextRegularBlack"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="4"
android:background="#drawable/rowbg"
android:gravity="top|left"
android:lines="4"
android:maxLength="2000"
android:tag="200" />
</LinearLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp" >
<com.esp.leadtransit.uc.EspTextView
android:id="#+id/tv_waiver"
style="#style/TextRegularWhite_other"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:tag="200"
android:text="DNC Waiver:" />
<ToggleButton
android:id="#+id/tbtn_dnc_waiver"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/tv_waiver"
android:background="#drawable/toggle_button"
android:textOff=""
android:textOn="" />
</RelativeLayout>
<LinearLayout
android:id="#+id/ll_attachment"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="#ffffff"
android:orientation="vertical" >
<Button
android:id="#+id/btn_submit"
style="#style/TextRegularBlack"
android:layout_width="120dp"
android:layout_height="40dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:background="#drawable/selector_menu_btn_orange"
android:tag="200"
android:text="Submit"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
I have a problem with dividing the LinearLayout(Horizontal) into three columns (vertical columns).
Can someone look into the XML and advise ?
XML below:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="40"
android:orientation="vertical" >
<ImageButton
android:id="#+id/ibTakeCheckPhoto"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_weight="1"
android:src="#drawable/camera" />
</LinearLayout>
<View
android:layout_width="2dp"
android:layout_height="fill_parent"
android:background="#android:color/darker_gray" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="30"
android:orientation="vertical" >
<TextView
android:id="#+id/checkLayoutIDTV"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Check Number"
android:textStyle="bold" />
<TextView
android:id="#+id/checkLayout_amountTV"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Amount"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="30"
android:orientation="vertical" >
<EditText
android:id="#+id/checkLayoutIDET"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Check No."
android:inputType="number" >
</EditText>
<EditText
android:id="#+id/checkLayout_amounET"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="5"
android:hint="Amount"
android:inputType="number" />
</LinearLayout>
<?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="wrap_content"
android:orientation="horizontal"
android:weightSum="100" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="24.33"
android:orientation="vertical" >
<TableLayout
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/checkLayoutIDTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Check Number"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="bold" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/checkLayout_amountTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Amount"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="bold" />
</TableRow>
</TableLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical" >
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TableRow
android:id="#+id/tableRow6"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/EditText01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="5"
android:hint="Amount"
android:inputType="number" />
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/checkLayoutIDET"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="edit2"
android:inputType="number" />
</TableRow>
<TableRow
android:id="#+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/checkLayout_amounET"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="5"
android:hint="Amount"
android:inputType="number" >
<requestFocus />
</EditText>
</TableRow>
</TableLayout>
</LinearLayout>
</LinearLayout>
may b it fulfill your requirement..
Use android:layout_width="fill_parent" instead of android:layout_width="0dp" in ImageButton, TextView and EditText.
Resulting layout will look like this
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="40"
android:orientation="vertical" >
<ImageButton
android:id="#+id/ibTakeCheckPhoto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="left"
android:src="#drawable/camera" />
</LinearLayout>
<View
android:layout_width="2dp"
android:layout_height="fill_parent"
android:background="#android:color/darker_gray" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="30"
android:orientation="vertical" >
<TextView
android:id="#+id/checkLayoutIDTV"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:text="Check Number"
android:textStyle="bold" />
<TextView
android:id="#+id/checkLayout_amountTV"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:text="Amount"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="30"
android:orientation="vertical" >
<EditText
android:id="#+id/checkLayoutIDET"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Check No."
android:inputType="number" >
</EditText>
<EditText
android:id="#+id/checkLayout_amounET"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="5"
android:hint="Amount"
android:inputType="number" />
</LinearLayout>
</LinearLayout>
And extract hardcoded strings to res/values/strings.xml
i think this is what you wanted
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="10" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:orientation="vertical" >
<ImageButton
android:id="#+id/ibTakeCheckPhoto"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="left"
android:layout_weight="1"
android:src="#drawable/ic_launcher" />
</LinearLayout>
<View
android:layout_width="2dp"
android:layout_height="fill_parent"
android:background="#android:color/darker_gray" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:orientation="vertical" >
<TextView
android:id="#+id/checkLayoutIDTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Check Number"
android:textStyle="bold" />
<TextView
android:id="#+id/checkLayout_amountTV"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Amount"
android:textStyle="bold" />
</LinearLayout>
<View
android:layout_width="2dp"
android:layout_height="fill_parent"
android:background="#android:color/darker_gray" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:orientation="vertical" >
<EditText
android:id="#+id/checkLayoutIDET"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Check No."
android:inputType="number" >
</EditText>
<EditText
android:id="#+id/checkLayout_amounET"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="5"
android:hint="Amount"
android:inputType="number" />
</LinearLayout>
I have a tablelayout with weights for a 4 button grid. The problem is that I have on button that is in a relative layout in a tablerow which doesn't format correctly. If I have the height set to wrap content the result is this:
If I set it to fill_parent:
I can't get the button to properly fill its height weight. If I take out the relative layout it works fine. I've tried putting both in separate linear layouts to no avail.
Here is my code:
<TableLayout
android:id="#+id/tableLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/linearLayout"
android:layout_margin="10dp"
android:weightSum="2" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:minHeight="100dp" >
<Button
android:id="#+id/searchBtn"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".5"
android:background="#drawable/yellow_btn"
android:minHeight="100dp"
android:text="Search"
android:textColor="#1d357d"
android:textSize="20dp"
android:textStyle="bold" />
<RelativeLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".5"
android:minHeight="100dp" >
<Button
android:id="#+id/savedBtn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/yellowds"
android:minHeight="100dp"
android:text="Saved Searches"
android:textColor="#1d357d"
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:id="#+id/newItemsOverlay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/savedBtn"
android:layout_alignTop="#+id/savedBtn"
android:background="#drawable/badge_circle"
android:text="10"
android:textColor="#FFF"
android:textSize="16sp"
android:textStyle="bold" />
</RelativeLayout>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="30dip"
android:layout_weight="1"
android:minHeight="100dp" >
<Button
android:id="#+id/checkNowBtn"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".5"
android:background="#drawable/yellowds"
android:minHeight="100dp"
android:text="Check Now"
android:textColor="#1d357d"
android:textSize="20dp"
android:textStyle="bold" />
<Button
android:id="#+id/settingsBtn"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".5"
android:background="#drawable/yellowds"
android:minHeight="100dp"
android:text="Settings"
android:textColor="#1d357d"
android:textSize="20dp"
android:textStyle="bold" />
</TableRow>
</TableLayout>
Try with this :
<?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" >
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</LinearLayout>
<TableLayout
android:id="#+id/tableLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/linearLayout"
android:layout_margin="10dp"
android:weightSum="2" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:minHeight="100dp" >
<RelativeLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".5" >
<Button
android:id="#+id/searchBtn"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#cccccc"
android:minHeight="100dp"
android:text="Search"
android:textColor="#1d357d"
android:textSize="20dp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".5" >
<Button
android:id="#+id/savedBtn"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#cccccc"
android:minHeight="100dp"
android:text="Saved Searches"
android:textColor="#1d357d"
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:id="#+id/newItemsOverlay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/savedBtn"
android:layout_alignTop="#+id/savedBtn"
android:background="#ff0000"
android:text="10"
android:textColor="#FFF"
android:textSize="16sp"
android:textStyle="bold" />
</RelativeLayout>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="30dip"
android:layout_weight="1"
android:minHeight="100dp" >
<RelativeLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".5" >
<Button
android:id="#+id/checkNowBtn"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#cccccc"
android:minHeight="100dp"
android:text="Check Now"
android:textColor="#1d357d"
android:textSize="20dp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".5" >
<Button
android:id="#+id/settingsBtn"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#cccccc"
android:minHeight="100dp"
android:text="Settings"
android:textColor="#1d357d"
android:textSize="20dp"
android:textStyle="bold" />
</RelativeLayout>
</TableRow>
</TableLayout>
</RelativeLayout>
This will solve your problem.
Thanks.
I have created a TableLayout where I want each row to have the same height, regardless of it's content.
How can I do this?
Here is my code. Each row element get the same width, but the heights are not equal. What am I doing wrong?
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:background="#color/grey"
android:padding="1dip" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#color/grey" >
<LinearLayout
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#color/white"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical"
android:layout_marginBottom="5dip"
android:layout_marginTop="2dip"
android:layout_weight="1"
android:background="#color/white"
android:gravity="center_horizontal"
android:text="#string/car_make"
android:textStyle="bold" />
<TextView
android:id="#+id/carMake"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical"
android:layout_marginLeft="1dip"
android:layout_weight="1"
android:background="#color/white"
android:gravity="center_horizontal"
android:text="#string/car_detail" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#color/white"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical"
android:layout_marginBottom="5dip"
android:layout_marginTop="2dip"
android:layout_weight="1"
android:background="#color/white"
android:gravity="center_horizontal"
android:text="#string/car_model"
android:textStyle="bold" />
<TextView
android:id="#+id/carModel"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="#color/white"
android:gravity="center_horizontal"
android:text="#string/car_detail" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#color/white"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical"
android:layout_marginBottom="5dip"
android:layout_marginTop="2dip"
android:layout_weight="1"
android:background="#color/white"
android:gravity="center_horizontal"
android:text="#string/car_version"
android:textStyle="bold" />
<TextView
android:id="#+id/carYear"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="#color/white"
android:gravity="center_horizontal"
android:text="#string/car_year" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="1dip"
android:layout_weight="1"
android:background="#color/grey" >
<LinearLayout
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#color/white"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginBottom="5dip"
android:layout_marginTop="2dip"
android:background="#color/white"
android:gravity="center_horizontal"
android:text="#string/car_year"
android:textStyle="bold" />
<TextView
android:id="#+id/carYear"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="#color/white"
android:gravity="center_horizontal"
android:text="#string/car_year" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#color/white"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginBottom="5dip"
android:layout_marginTop="2dip"
android:background="#color/white"
android:gravity="center_horizontal"
android:text="#string/car_mileage"
android:textStyle="bold" />
<TextView
android:id="#+id/carYear"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="#color/white"
android:gravity="center_horizontal"
android:text="#string/car_year" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#color/white"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginBottom="5dip"
android:layout_marginTop="2dip"
android:background="#color/white"
android:gravity="center_horizontal"
android:text="#string/car_engine_capacity"
android:textStyle="bold" />
<TextView
android:id="#+id/carYear"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical"
android:background="#color/white"
android:gravity="center_horizontal"
android:text="#string/car_year" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="1dip"
android:layout_weight="1"
android:background="#color/grey" >
<LinearLayout
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#color/white"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginBottom="5dip"
android:background="#color/white"
android:gravity="center_horizontal"
android:text="#string/car_engine_type"
android:textStyle="bold" />
<TextView
android:id="#+id/carYear"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="#color/white"
android:gravity="center_horizontal"
android:text="#string/car_year" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#color/white"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginBottom="5dip"
android:background="#color/white"
android:gravity="center_horizontal"
android:text="#string/car_exterior_color"
android:textStyle="bold" />
<TextView
android:id="#+id/carYear"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="#color/white"
android:gravity="center_horizontal"
android:text="#string/car_year" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#color/white"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginBottom="5dip"
android:background="#color/white"
android:gravity="center_horizontal"
android:text="#string/car_city"
android:textStyle="bold" />
<TextView
android:id="#+id/carYear"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="#color/white"
android:gravity="center_horizontal"
android:text="#string/car_year" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="1dip"
android:layout_weight="1"
android:background="#color/grey" >
<LinearLayout
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#color/white"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginBottom="5dip"
android:background="#color/white"
android:gravity="center_horizontal"
android:text="#string/car_transmittion"
android:textStyle="bold" />
<TextView
android:id="#+id/carYear"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="#color/white"
android:gravity="center_horizontal"
android:text="#string/car_year" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#color/white"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginBottom="5dip"
android:background="#color/white"
android:gravity="center_horizontal"
android:text="#string/car_area"
android:textStyle="bold" />
<TextView
android:id="#+id/carYear"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="#color/white"
android:gravity="center_horizontal"
android:text="#string/car_year" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#color/white"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginBottom="5dip"
android:background="#color/white"
android:gravity="center_horizontal"
android:text="#string/car_registered_city"
android:textStyle="bold" />
<TextView
android:id="#+id/carYear"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="#color/white"
android:gravity="center_horizontal"
android:text="#string/car_year" />
</LinearLayout>
</TableRow>
</TableLayout>
Introduced in API 11, you can set android:measureWithLargestChild="true" on the TableLayout and android:layout_weight="1" on each TableRow.
here is your solution :
<?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:orientation="vertical" >
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="4" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="#B0B0B0" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="#B0B0B0" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="#B0B0B0" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#B0B0B0" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="1dp"
android:orientation="vertical"
android:weightSum="4" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="#B0B0B0" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="#B0B0B0" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="#B0B0B0" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#B0B0B0" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="1dp"
android:orientation="vertical"
android:weightSum="4" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="#B0B0B0" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="#B0B0B0" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="#B0B0B0" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#B0B0B0" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="1dp"
android:orientation="vertical"
android:weightSum="4" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="#B0B0B0" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="#B0B0B0" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="#B0B0B0" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#B0B0B0" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="1dp"
android:orientation="vertical"
android:weightSum="4" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="#B0B0B0" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="#B0B0B0" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="#B0B0B0" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#B0B0B0" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="1dp"
android:orientation="vertical"
android:weightSum="4" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="#B0B0B0" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="#B0B0B0" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="#B0B0B0" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#B0B0B0" />
</TableRow>
</TableLayout>
</LinearLayout>
here is a solution:
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_gravity="fill"
/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_gravity="fill"
/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_gravity="fill"
/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_gravity="fill"
/>
</TableRow>
I just came across this issue and solved it.
It turns out Sunny's answer worked for me.
Though as mentioned in the comment, I could figure out if it works by just reading it. I am a newbee so cannot neither leave comment nor vote it to useful. Therefore I am posting it here.
The idea is that you let TableRow to decide the height of the row. By setting layout_height to wrap_content, the height of the row is depends on the contents which is TextView.
Since the border line of the cell would be the boundary of TextView, the layout_height should be match_parent.
I wish it is helpful for Android newbee (yes i am new to android too).
<TableRow
android:layout_width="fill_parent"
android:layout_height="xxdip" // HERE define a fixed size
Below Answer Deprecated Now :
You can Change in your TableRow -> LinearLayout
<LinearLayout
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#color/white"
android:orientation="vertical" >