When I am try to develop a simple table layout it's occur a problem. The layout is works fine for big screen. But when I'm use that in small phone then the problem create. The full rows aren't visible.
Can anyone help me out? I just want to make a simple table layout like that:
here what I made xml layout
<TableLayout
android:layout_below="#+id/jonosonkha"
android:layout_width="match_parent"
android:layout_height="250dp"
android:stretchColumns="5">
<TableRow>
<TextView
android:textColor="#000"
android:background="#ffea00"
android:textSize="20sp"
android:text="পরিবার"
android:paddingLeft="5dp" />
<TextView
android:background="#000"
android:textColor="#fff"
android:textSize="20sp"
android:text="পুরুষ"
android:gravity="left"
android:paddingLeft="5dp"/>
<TextView
android:background="#ffea00"
android:textSize="20sp"
android:text="মহিলা"
android:textColor="#000"
android:gravity="center"
android:paddingLeft="5dp" />
<TextView
android:background="#000"
android:textSize="20sp"
android:text="গড় সদস্য"
android:gravity="left"
android:textColor="#fff"
android:paddingLeft="5dp" />
<TextView
android:background="#ffea00"
android:textColor="#000"
android:textSize="20sp"
android:text="ঘনত্ব/কি.মি"
android:gravity="left"
android:paddingLeft="5dp" />
</TableRow>
<TableRow
android:layout_marginTop="2dp"
>
<TextView
android:textColor="#000"
android:background="#ffea00"
android:textSize="16sp"
android:text="৮৯৮৬৩"
android:paddingLeft="5dp" />
<TextView
android:background="#000"
android:textColor="#fff"
android:textSize="16sp"
android:text="২০৫০৭৫"
android:gravity="center"
android:paddingLeft="5dp"/>
<TextView
android:background="#ffea00"
android:textSize="16sp"
android:text="২০৯১১৩"
android:textColor="#000"
android:gravity="center"
android:paddingLeft="5dp" />
<TextView
android:background="#000"
android:textSize="16sp"
android:text="৪.৫৪"
android:gravity="center"
android:textColor="#fff"
android:paddingLeft="5dp" />
<TextView
android:background="#ffea00"
android:textColor="#000"
android:textSize="16sp"
android:text="২১৩৮"
android:gravity="left"
android:paddingLeft="5dp" />
</TableRow>
</TableLayout>
It's works fine for big screen but the problem is some of rows are covered by the small screen. Any solution please.
You want to divide five TextView .
You can add android:layout_width="0dp" 、android:layout_height="match_parent" and android:layout_weight="1" in your TextView .
You can try this .
<TableLayout
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_below="#+id/jonosonkha"
android:stretchColumns="5">
<TableRow>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#ffea00"
android:paddingLeft="5dp"
android:text="পরিবার"
android:textColor="#000"
android:textSize="20sp"/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#000"
android:gravity="left"
android:paddingLeft="5dp"
android:text="পুরুষ"
android:textColor="#fff"
android:textSize="20sp"/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#ffea00"
android:gravity="center"
android:paddingLeft="5dp"
android:text="মহিলা"
android:textColor="#000"
android:textSize="20sp"/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#000"
android:gravity="left"
android:paddingLeft="5dp"
android:text="গড় সদস্য"
android:textColor="#fff"
android:textSize="20sp"/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#ffea00"
android:gravity="left"
android:paddingLeft="5dp"
android:text="ঘনত্ব/কি.মি"
android:textColor="#000"
android:textSize="20sp"/>
</TableRow>
<TableRow
android:layout_marginTop="2dp">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#ffea00"
android:paddingLeft="5dp"
android:text="৮৯৮৬৩"
android:textColor="#000"
android:textSize="16sp"/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#000"
android:gravity="center"
android:paddingLeft="5dp"
android:text="২০৫০৭৫"
android:textColor="#fff"
android:textSize="16sp"/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#ffea00"
android:gravity="center"
android:paddingLeft="5dp"
android:text="২০৯১১৩"
android:textColor="#000"
android:textSize="16sp"/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#000"
android:gravity="center"
android:paddingLeft="5dp"
android:text="৪.৫৪"
android:textColor="#fff"
android:textSize="16sp"/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#ffea00"
android:gravity="left"
android:paddingLeft="5dp"
android:text="২১৩৮"
android:textColor="#000"
android:textSize="16sp"/>
</TableRow>
</TableLayout>
Output
You should define the width attribute of the table rows, like:
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
and the weight attribute of all the Textviews:
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#000"
android:background="#ffea00"
android:textSize="20sp"
android:text="পরিবার"
android:paddingLeft="5dp" />
Related
I want to make following layout in android but unable to make because i new to table layout and tried a lot to fix column spans and row spans.
This is what i had tried last, but the problem is the heading in first column, i want a row span of 2 but unable to do that so i put another blank row there.
<LinearLayout
android:id="#+id/fillable_area"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal">
<TableLayout
android:id="#+id/fixed_column_table"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_gravity="center_horizontal"
android:padding="2dp"
android:text="Account"
android:textAlignment="center"
android:textColor="#color/black"
android:textSize="12sp"
android:textStyle="bold" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_gravity="center_horizontal"
android:padding="2dp"
android:text=""
android:textAlignment="center"
android:textColor="#color/black"
android:textSize="12sp"
android:textStyle="bold" />
</TableRow>
</TableLayout>
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="5dp">
<TableLayout
android:id="#+id/scrollable_table"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="*">
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_gravity="center_horizontal"
android:layout_span="2"
android:padding="2dp"
android:paddingStart="10dp"
android:text="Opening Balance"
android:textAlignment="center"
android:textColor="#color/black"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:layout_gravity="center_horizontal"
android:layout_span="2"
android:padding="2dp"
android:paddingStart="10dp"
android:text="Transaction During Period"
android:textAlignment="center"
android:textColor="#color/black"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:layout_gravity="center_horizontal"
android:layout_span="2"
android:padding="2dp"
android:paddingStart="10dp"
android:text="Closing Balance"
android:textAlignment="center"
android:textColor="#color/black"
android:textSize="12sp"
android:textStyle="bold" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:background="#FFC7C7"
android:padding="2dp"
android:paddingStart="10dp"
android:text="Debit"
android:textAlignment="textEnd"
android:textColor="#color/black"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:background="#FBFFC7"
android:padding="2dp"
android:paddingStart="10dp"
android:text="Credit"
android:textAlignment="textEnd"
android:textColor="#color/black"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:background="#FFC7C7"
android:padding="2dp"
android:paddingStart="10dp"
android:text="Debit"
android:textAlignment="textEnd"
android:textColor="#color/black"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:background="#FBFFC7"
android:padding="2dp"
android:paddingStart="10dp"
android:text="Credit"
android:textAlignment="textEnd"
android:textColor="#color/black"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:background="#FFC7C7"
android:padding="2dp"
android:paddingStart="10dp"
android:text="Debit"
android:textAlignment="textEnd"
android:textColor="#color/black"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:background="#FBFFC7"
android:padding="2dp"
android:paddingStart="10dp"
android:text="Credit"
android:textAlignment="textEnd"
android:textColor="#color/black"
android:textSize="12sp"
android:textStyle="bold" />
</TableRow>
</TableLayout>
</HorizontalScrollView>
</LinearLayout>
Data in all rows are dynamic except headings.
Please help me.
Thanks
as you can see, they arranged in a table layout, i set their layout weight to 1 and their weight sum to 4, at first they are all equal in width, but that changes when the nunber has a lot of digits, what to do?
i thought using a table layout was more convenient than multiple linear layouts haha
layout:
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#android:color/holo_blue_bright"
android:weightSum="4">
<TextView
android:id="#+id/textView9"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Food"
android:textSize="12sp" />
<TextView
android:id="#+id/textView10"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Supplies"
android:textSize="12sp" />
<TextView
android:id="#+id/textView11"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Transport"
android:textSize="12sp" />
<TextView
android:id="#+id/textView12"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Misc"
android:textSize="12sp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="2dp"
android:layout_weight="1">
<TextView
android:id="#+id/tvTotalExpenses"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="0"
android:textSize="18sp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#android:color/holo_blue_bright"
android:weightSum="4">
<TextView
android:id="#+id/tvFoodExpense"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="0"
android:textSize="14sp" />
<TextView
android:id="#+id/tvSuppliesExpense"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="0"
android:textSize="14sp" />
<TextView
android:id="#+id/tvTransportExpense"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="0"
android:textSize="14sp" />
<TextView
android:id="#+id/tvMiscExpense"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="0"
android:textSize="14sp" />
</TableRow>
</TableLayout>
You are mentioning layout weight but it will not work properly unless you set the width to 0dp so set layout_width to 0dp like this
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#android:color/holo_blue_bright"
android:weightSum="4">
<TextView
android:id="#+id/textView9"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Food"
android:textSize="12sp" />
<TextView
android:id="#+id/textView10"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Supplies"
android:textSize="12sp" />
<TextView
android:id="#+id/textView11"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Transport"
android:textSize="12sp" />
<TextView
android:id="#+id/textView12"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Misc"
android:textSize="12sp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="2dp"
android:layout_weight="1">
<TextView
android:id="#+id/tvTotalExpenses"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="0"
android:textSize="18sp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#android:color/holo_blue_bright"
android:weightSum="4">
<TextView
android:id="#+id/tvFoodExpense"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="0"
android:textSize="14sp" />
<TextView
android:id="#+id/tvSuppliesExpense"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="5000000"
android:gravity="center"
android:textSize="14sp" />
<TextView
android:id="#+id/tvTransportExpense"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="50000"
android:textSize="14sp" />
<TextView
android:id="#+id/tvMiscExpense"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="0"
android:textSize="14sp" />
</TableRow>
</TableLayout>
I am very new to xamarin.andriod, I am trying to design a table with many rows. Everything is fine but I am not able to get a separator properly for rows.
Here is my code:
<TableLayout
android:layout_margin="10dp"
android:minWidth="25px"
android:minHeight="50px"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/tableLayout1"
android:layout_gravity="center"
android:showDividers="middle"
android:stretchColumns="*"
>
<TableRow
android:background="#D3D3D3"
android:id="#+id/tableHeader1"
android:maxLines="1"
android:ellipsize="end"
android:maxEms="3"
android:singleLine="true"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:paddingTop="1dp"
android:paddingLeft="1dp"
android:paddingRight="1dp"
android:paddingBottom="1dp"
android:gravity="center">
<TextView
android:text="UserName"
android:textColor="#343434"
android:id="#+id/username"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:gravity="center" />
<TextView
android:text="UserName"
android:textColor="#343434"
android:id="#+id/username1"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:gravity="center" />
<TextView
android:text="UserName"
android:textColor="#343434"
android:id="#+id/username2"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:gravity="center" />
<TextView
android:text="UserName"
android:textColor="#343434"
android:id="#+id/username3"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:gravity="center" />
<TextView
android:text="!"
android:textColor="#343434"
android:id="#+id/rowNotFilledIndication"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:gravity="center"
android:visibility="invisible"
android:tag="RowIncomplete" />
<TextView
android:text="UserName"
android:textColor="#343434"
android:id="#+id/username4"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:gravity="center" />
<TextView
android:text="UserName"
android:textColor="#343434"
android:id="#+id/username5"
android:gravity="center"
android:layout_height="wrap_content"
android:layout_gravity="center" />
<TextView
android:text="UserName"
android:textColor="#343434"
android:id="#+id/username3"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:gravity="center" />
</TableRow>
</TableLayout>
And here is the output I am getting
But I just want a ending line for each row completion instead of two lines for the row.
Is there any way to get only one line after the row completion?
try to use a view, make sure you set your show:divider to none
<View
android:id="#+id/view"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#color/colorPrimary"
/>
I am developing an android application. On the preview the view is presanting the way I have set it but when I run it on a device I am seeing spaces on it right and left side.
Screen shots are attached for the better understanding of the problem.
Below is the code of my layout.
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="------"
>
<!-- TODO: Update blank fragment layout -->
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/scrollView"
android:scrollbars="none"
android:layout_gravity="center">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/screen_background">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/telephone_number"
android:id="#+id/telephonNumberTextView"
android:phoneNumber="false"
android:textColor="#android:color/white"
android:layout_marginTop="10dp"
android:layout_marginBottom="5dp"
android:paddingLeft="2dp" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:id="#+id/phoneNumberEditText"
android:layout_weight="1"
android:clickable="true"
android:singleLine="true"
android:background="#drawable/edittext"
android:paddingLeft="4dp"
android:textAlignment="textStart" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/telephone_extension"
android:id="#+id/telephoneExtensionTextView"
android:layout_marginTop="10dp"
android:layout_gravity="left|center_vertical"
android:textColor="#android:color/white"
android:layout_marginBottom="5dp"
android:paddingLeft="2dp"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:id="#+id/telephoneExtensionEditText"
android:background="#drawable/edittext"
android:singleLine="true"
android:paddingLeft="4dp"
android:layout_weight="1"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/email_id"
android:id="#+id/emailIdTextView"
android:layout_gravity="left|center_vertical"
android:textColor="#android:color/white"
android:layout_marginTop="10dp"
android:layout_marginBottom="5dp"
android:paddingLeft="2dp"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10"
android:id="#+id/emailIdEditText"
android:layout_gravity="center_vertical"
android:singleLine="true"
android:layout_weight="1"
android:background="#drawable/edittext"
android:paddingLeft="4dp"
android:layout_margin="5dp" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/problem_type"
android:id="#+id/problemTypeTextView"
android:layout_gravity="left|center_vertical"
android:textColor="#android:color/white"
android:layout_marginTop="10dp"
android:layout_marginBottom="5dp"
android:paddingLeft="2dp"/>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:text="#string/fetch_problem_types"
android:id="#+id/button"
android:background="#drawable/buttonback"
android:textColor="#android:color/white"
android:layout_gravity="center"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/location"
android:id="#+id/locationTextView"
android:layout_gravity="left|center_vertical"
android:textColor="#android:color/white"
android:layout_marginTop="10dp"
android:layout_marginBottom="5dp"
android:paddingLeft="2dp"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textPostalAddress"
android:ems="10"
android:id="#+id/locationEditText"
android:layout_gravity="bottom"
android:singleLine="true"
android:background="#drawable/edittext"
android:paddingLeft="4dp"
android:layout_weight="1" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/brief_desc"
android:id="#+id/briefDescTextView"
android:layout_gravity="left|center_vertical"
android:textColor="#android:color/white"
android:layout_marginTop="10dp"
android:layout_marginBottom="5dp"
android:paddingLeft="2dp"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/briefDescEditText"
android:singleLine="true"
android:layout_gravity="bottom"
android:background="#drawable/edittext"
android:paddingLeft="4dp"
android:layout_weight="1" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/doc_desc"
android:id="#+id/docDescTextView"
android:layout_gravity="left|center_vertical"
android:textColor="#android:color/white"
android:layout_marginTop="10dp"
android:layout_marginBottom="5dp"
android:paddingLeft="2dp"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/docDescEditText"
android:layout_gravity="bottom"
android:singleLine="true"
android:background="#drawable/edittext"
android:paddingLeft="4dp"
android:layout_weight="1" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/approval_memo"
android:id="#+id/approvalMemoTextView"
android:layout_gravity="left|center_vertical"
android:layout_marginTop="10dp"
android:textColor="#android:color/white"
android:layout_marginBottom="5dp"
android:paddingLeft="2dp"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/approvalMemoEditText"
android:layout_gravity="bottom"
android:singleLine="true"
android:background="#drawable/edittext"
android:paddingLeft="4dp"
android:layout_weight="1"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/requester_Name"
android:id="#+id/requesterNameTextView"
android:layout_gravity="left|center_vertical"
android:layout_marginTop="10dp"
android:textColor="#android:color/white"
android:layout_marginBottom="5dp"
android:paddingLeft="2dp"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/requesterNameEditText"
android:layout_gravity="bottom"
android:singleLine="true"
android:background="#drawable/edittext"
android:layout_weight="1"
android:layout_marginBottom="5dp"
android:paddingLeft="4dp"
/>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:text="#string/submit_button_title"
android:id="#+id/submitButton"
android:layout_gravity="center_vertical"
android:background="#drawable/buttonback"
android:textColor="#android:color/white"
android:layout_marginTop="10dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_marginBottom="5dp"/>
</LinearLayout>
</ScrollView>
</LinearLayout>
The problem (most probably) lies in the top level XML. I assume you posted only the content.xml which is included my activity_main.xml, because I can't see the Floating Action Button.
I guess you used the build-in generator to create layouts for you and edited the content.xml one. The paddings are defined inside the activity_main.xml one. Delete them and you are good to go.
Remove layout android:layout_margin="5dp" in Email Id EditText
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10"
android:id="#+id/emailIdEditText"
android:layout_gravity="center_vertical"
android:singleLine="true"
android:layout_weight="1"
android:background="#drawable/edittext"
android:paddingLeft="4dp" />
I have a ListView with 10 columns and an header. As you can see in the following picture, the rows are not aligned with the header.
If the text in the TextViews was centered it seems like the problem would solve.
I tried many things, but none of them worked.
*NOTE: Please don't tell me to use a TableLayout. I already did it but the loading was much slower.
Here is the xml of the ListView:
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#id/LinearLayout1"
android:background="#d9d9d9" >
</ListView>
Here is the list_header xml:
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/TableRow1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/header_back"
android:orientation="horizontal" >
<TextView
android:id="#+id/stockNumTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:text="#string/stockNum"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="16sp" />
<TextView
android:id="#+id/shapeTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:text="#string/shape"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="16sp" />
<TextView
android:id="#+id/weightTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:text="#string/weight"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="16sp" />
<TextView
android:id="#+id/colorTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:text="#string/color"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="16sp" />
<TextView
android:id="#+id/clarityTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:text="#string/clarity"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="16sp" />
<TextView
android:id="#+id/cutGradeTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:text="#string/cutGrade"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="16sp" />
<TextView
android:id="#+id/labTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:text="#string/labb"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="16sp" />
<TextView
android:id="#+id/priceTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:text="#string/price"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="16sp" />
<TextView
android:id="#+id/discountTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:text="#string/disc"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="16sp" />
<TextView
android:id="#+id/statusTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:text="#string/status"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="16sp" />
</TableRow>
Here is the list_item xml:
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/TableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/list_item_selector"
android:clickable="true"
android:orientation="horizontal" >
<TextView
android:id="#+id/stockNumTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="4dp"
android:layout_marginTop="4dp"
android:layout_weight="1"
android:text="#string/stockNum"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/black"
android:textSize="14sp" />
<TextView
android:id="#+id/shapeTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="4dp"
android:layout_marginTop="4dp"
android:layout_weight="1"
android:text="#string/shape"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/black"
android:textSize="14sp" />
<TextView
android:id="#+id/weightTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="4dp"
android:layout_marginTop="4dp"
android:layout_weight="1"
android:text="#string/weight"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/black"
android:textSize="14sp" />
<TextView
android:id="#+id/colorTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="4dp"
android:layout_marginTop="4dp"
android:layout_weight="1"
android:text="#string/color"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/black"
android:textSize="14sp" />
<TextView
android:id="#+id/clarityTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="4dp"
android:layout_marginTop="4dp"
android:layout_weight="1"
android:text="#string/clarity"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/black"
android:textSize="14sp" />
<TextView
android:id="#+id/cutGradeTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="4dp"
android:layout_marginTop="4dp"
android:layout_weight="1"
android:text="#string/cutGrade"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/black"
android:textSize="14sp" />
<TextView
android:id="#+id/labTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="4dp"
android:layout_marginTop="4dp"
android:layout_weight="1"
android:text="#string/lab"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/black"
android:textSize="14sp" />
<TextView
android:id="#+id/priceTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="4dp"
android:layout_marginTop="4dp"
android:layout_weight="1"
android:text="#string/price"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/black"
android:textSize="14sp" />
<TextView
android:id="#+id/discountTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="4dp"
android:layout_marginTop="4dp"
android:layout_weight="1"
android:text="#string/disc"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/black"
android:textSize="14sp" />
<TextView
android:id="#+id/statusTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="4dp"
android:layout_marginTop="4dp"
android:layout_weight="1"
android:text="#string/status"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/red"
android:textSize="14sp" />
</TableRow>
Thank you!
make textsizes the same for both header and items- you ddi 14sp for items and 16sp for header, and also remove margin from items, if the issue still keep same, put margin/padding to list items