I have a following xml layout in my project (incidentally, if you notice something else that is also seemingly wrong/not so good yet, I'd appreciate you let me know about it!) and my problem is the attribute "wrap_contents" doesn't work at the last TextView ("EEE", txt4). Is there any regulation I overlook?
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<TableLayout
android:id="#+id/Table"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical">
<TextView
android:id="#+id/txt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="AAA"
android:textColor="#color/white" />
<Spinner
android:id="#+id/spn1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:entries="#array/array1" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/edt1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="BBB"
android:textColor="#color/white" />
<Spinner
android:id="#+id/spn2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:entries="#array/Tounyuhou" />
<EditText
android:id="#+id/edt2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="5"
android:inputType="numberSigned"/>
<TextView
android:id="#+id/txt2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="CCC" android:textColor="#color/white"
android:gravity="center_vertical|center_horizontal"
android:textSize="18sp"/>
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/txt3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:text="DDD"
android:textColor="#color/white" />
<EditText
android:id="#+id/edt3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right|center_vertical">
</EditText>
<TextView
android:id="#+id/txt4"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="EEE"
android:textColor="#color/white"
android:gravity="center_vertical|center_horizontal"
android:textSize="20sp"/>
</TableRow>
</TableLayout>
</merge>
here you define all the rows in same layout , but with different number of views, like row1 contain 2 , row2 contain 4 then row3 contain 3 views,
so it gives problem,
so my suggetion take different tablelayout for third row.
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<TableLayout
android:id="#+id/mainTable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<TableRow
android:id="#+id/mainTable_tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical">
<TableLayout
android:id="#+id/Table"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical">
<TextView
android:id="#+id/txt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="AAA"
android:textColor="#color/white" />
<Spinner
android:id="#+id/spn1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:entries="#array/array1" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/edt1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="BBB"
android:textColor="#color/white" />
<Spinner
android:id="#+id/spn2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:entries="#array/Tounyuhou" />
<EditText
android:id="#+id/edt2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="5"
android:inputType="numberSigned"/>
<TextView
android:id="#+id/txt2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="CCC" android:textColor="#color/white"
android:gravity="center_vertical|center_horizontal"
android:textSize="18sp"/>
</TableRow>
</TableLayout>
</TableRow>
<TableRow
android:id="#+id/mainTable_tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical">
<TableLayout
android:id="#+id/Table2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<TableRow
android:id="#+id/table2_tableRow3"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/txt3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:text="DDD"
android:textColor="#color/white" />
<EditText
android:id="#+id/edt3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right|center_vertical">
</EditText>
<TextView
android:id="#+id/txt4"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="EEE"
android:textColor="#color/white"
android:gravity="center_vertical|center_horizontal"
android:textSize="20sp"/>
</TableRow>
</TableLayout>
</TableRow>
</TableLayout>
</merge>
Related
I am trying to add a table inside a linear layout. Inside my linear layout there is textview, spinner. When I try to add a table layout it doesn't align correctly. Below is my code
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/cardLayout"
android:orientation="vertical">
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Product"
android:gravity="center"
android:textStyle="bold"
android:textSize="18sp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10sp"
android:layout_margin="10sp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".5"
android:orientation="vertical">
<Spinner
android:id="#+id/product_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
/>
</LinearLayout>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
>
<TableRow android:background="#0079D6" android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Product Name" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Sale" />
</TableRow>
<TableRow android:background="#DAE8FC" android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="" />
</TableRow>
</TableLayout>
</LinearLayout>
</LinearLayout>
Output
Expected Output
I must be missing something that I don't know. How can I align them equally just like in the above image
Any help would be highly appreciated.
Try using below code:
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Product"
android:gravity="center"
android:textStyle="bold"
android:textSize="18sp"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center">
<Spinner
android:id="#+id/product_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
/>
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:layout_gravity="center"
>
<TableRow android:background="#0079D6" android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Product Name" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Sale" />
</TableRow>
<TableRow android:background="#DAE8FC" android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="" />
</TableRow>
</TableLayout>
</LinearLayout>
</LinearLayout>
I am developing an application in which I am using a Table Layout. The first row of my table layout is as Header. Now I want something that the Header or first row should not be scrollable and other should be scrollable. My code is :
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:shrinkColumns="*" android:stretchColumns="*" android:background="#ffffff">
<!-- Row 1 with single column -->
<TableRow
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:gravity="center_horizontal">
<TextView
android:layout_width="match_parent" android:layout_height="wrap_content"
android:textSize="18sp" android:text="#string/com" android:layout_span="3"
android:padding="18dip" android:gravity="center"
android:textColor="#000"/>
</TableRow>
<!-- Row 2 with 3 columns -->
<TableRow
android:id="#+id/tableRow1"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="#b0b0b0"
android:gravity="center_horizontal">
<TextView
android:id="#+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="#string/c"
android:gravity="center"
android:textSize="18sp"
android:textAppearance="?android:attr/textAppearanceMedium" />
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:gravity="center_horizontal">
<TextView
android:id="#+id/TextView3"
android:text="#string/c1"
android:layout_weight="1"
android:gravity="center"/>
<TextView
android:id="#+id/TextView4"
android:text="#string/c2"
android:layout_weight="1"
android:gravity="center"/>
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="#b0b0b0"
android:gravity="center_horizontal">
<TextView
android:id="#+id/textView5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="#string/d"
android:gravity="center"
android:textSize="18sp"
android:textAppearance="?android:attr/textAppearanceMedium" />
</TableRow>
<!-- Row 3 with 2 columns -->
<TableRow
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:gravity="center_horizontal">
<TextView
android:id="#+id/TextView6"
android:text="#string/d1"
android:layout_weight="1"
android:gravity="center"/>
<TextView
android:id="#+id/TextView7"
android:text="#string/d2"
android:layout_weight="1"
android:gravity="center"/>
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="#b0b0b0"
android:gravity="center_horizontal">
<TextView
android:id="#+id/textView5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="#string/e"
android:gravity="center"
android:textSize="18sp"
android:textAppearance="?android:attr/textAppearanceMedium" />
</TableRow>
<!-- Row 3 with 2 columns -->
<TableRow
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:gravity="center_horizontal">
<TextView
android:id="#+id/TextView6"
android:text="#string/e1"
android:layout_weight="1"
android:gravity="center"/>
<TextView
android:id="#+id/TextView7"
android:text="#string/e2"
android:layout_weight="1"
android:gravity="center"/>
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="#b0b0b0"
android:gravity="center_horizontal">
<TextView
android:id="#+id/textView5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="#string/g"
android:gravity="center"
android:textSize="18sp"
android:textAppearance="?android:attr/textAppearanceMedium" />
</TableRow>
</TableLayout>
Can anybody please help me how to make first TextView as header and non-scrollable and other complete table as scrollable ..??
simple use this code in xml file its work...
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:orientation="vertical" >
<!-- Header aligned to top -->
<LinearLayout
android:id="#+id/headerView"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:shrinkColumns="*"
android:stretchColumns="*" >
<!-- Row 1 with single column -->
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_span="3"
android:gravity="center"
android:padding="18dip"
android:text="com"
android:textColor="#000"
android:textSize="18sp" />
</TableRow>
</TableLayout>
</LinearLayout>
<ScrollView
android:id="#+id/scrollablContent"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:shrinkColumns="*"
android:stretchColumns="*" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#b0b0b0"
android:gravity="center_horizontal" >
<TextView
android:id="#+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:gravity="center"
android:text="c"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="18sp" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<TextView
android:id="#+id/TextView3"
android:layout_weight="1"
android:gravity="center"
android:text="c1" />
<TextView
android:id="#+id/TextView4"
android:layout_weight="1"
android:gravity="center"
android:text="c2" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#b0b0b0"
android:gravity="center_horizontal" >
<TextView
android:id="#+id/textView5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:gravity="center"
android:text="d"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="18sp" />
</TableRow>
<!-- Row 3 with 2 columns -->
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<TextView
android:id="#+id/TextView6"
android:layout_weight="1"
android:gravity="center"
android:text="d1" />
<TextView
android:id="#+id/TextView7"
android:layout_weight="1"
android:gravity="center"
android:text="d2" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#b0b0b0"
android:gravity="center_horizontal" >
<TextView
android:id="#+id/textView5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:gravity="center"
android:text="e"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="18sp" />
</TableRow>
<!-- Row 3 with 2 columns -->
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<TextView
android:id="#+id/TextView6"
android:layout_weight="1"
android:gravity="center"
android:text="e1" />
<TextView
android:id="#+id/TextView7"
android:layout_weight="1"
android:gravity="center"
android:text="e2" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#b0b0b0"
android:gravity="center_horizontal" >
<TextView
android:id="#+id/textView5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:gravity="center"
android:text="g"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="18sp" />
</TableRow>
</TableLayout>
</ScrollView>
<RelativeLayout
android:id="#+id/footerView"
android:layout_width="wrap_content"
android:layout_height="72dp" >
<!-- Footer aligned to bottom -->
</RelativeLayout>
</LinearLayout>
Try some thing like this,
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:shrinkColumns="*" android:stretchColumns="*" android:background="#ffffff">
<TableRow
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:gravity="center_horizontal">
<TextView
android:layout_width="match_parent" android:layout_height="wrap_content"
android:textSize="18sp" android:text="#string/com" android:layout_span="3"
android:padding="18dip" android:gravity="center"
android:textColor="#000"/>
</TableRow>
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#b0b0b0"
android:gravity="center_horizontal" >
<TextView
android:id="#+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:gravity="center"
android:text="#string/c"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="18sp" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<TextView
android:id="#+id/TextView3"
android:layout_weight="1"
android:gravity="center"
android:text="#string/c1" />
<TextView
android:id="#+id/TextView4"
android:layout_weight="1"
android:gravity="center"
android:text="#string/c2" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#b0b0b0"
android:gravity="center_horizontal" >
<TextView
android:id="#+id/textView5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:gravity="center"
android:text="#string/d"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="18sp" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<TextView
android:id="#+id/TextView6"
android:layout_weight="1"
android:gravity="center"
android:text="#string/d1" />
<TextView
android:id="#+id/TextView7"
android:layout_weight="1"
android:gravity="center"
android:text="#string/d2" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#b0b0b0"
android:gravity="center_horizontal" >
<TextView
android:id="#+id/textView5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:gravity="center"
android:text="#string/e"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="18sp" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<TextView
android:id="#+id/TextView6"
android:layout_weight="1"
android:gravity="center"
android:text="#string/e1" />
<TextView
android:id="#+id/TextView7"
android:layout_weight="1"
android:gravity="center"
android:text="#string/e2" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#b0b0b0"
android:gravity="center_horizontal" >
<TextView
android:id="#+id/textView5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:gravity="center"
android:text="#string/g"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="18sp" />
</TableRow>
</LinearLayout>
</ScrollView>
</TableLayout>
After your First row , describe the scrollview
like this...
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</TableRow>
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</TableRow>
<TableRow
android:id="#+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</TableRow>
</LinearLayout>
</ScrollView>
</TableLayout>
You can create a LinearLayout for remaining table rows except header table row and add this LinearLayout to ScrollView, because ScrollView can have only one child.
Eg:
<ScrollView
android:id="#+id/scrollviewID"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
//your table rows
</LinearLayout>
</ScrollView>
In this screenshot :
I want the three fields after the TextView "vidy" to be closer to each other. Here is the layout xml :
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="*"
android:shrinkColumns="*"
style="#style/BazarStyle" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="#style/BazarTitleStyle"
android:layout_span="5"
android:gravity="center"
android:layout_marginBottom="5dp">
<TextView
android:id="#+id/title_tv"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:singleLine="true"
android:scrollHorizontally="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:textColor="#fff"
android:gravity="center"
style="#style/BazarStyleTransparent"/>
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/tvtype"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/od_type"
style="#style/BazarStyleLabel"
/>
<Spinner
android:id="#+id/type"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<requestFocus />
</Spinner>
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/tvproduit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/od_product"
style="#style/BazarStyleLabel" />
<Spinner
android:id="#+id/produit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</TableRow>
<TableRow
android:id="#+id/tableRow4"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/tvtsena"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/od_market"
style="#style/BazarStyleLabel" />
<Spinner
android:id="#+id/tsena"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</TableRow>
<TableRow
android:id="#+id/tableRow5"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/tvqte"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/od_quantity"
style="#style/BazarStyleLabel" />
<EditText
android:id="#+id/qte"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="number"/>
<EditText
android:id="#+id/fatra_qte"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</TableRow>
<TableRow
android:id="#+id/tableRow6"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/tvnorme"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/od_norm"
style="#style/BazarStyleLabel" />
<EditText
android:id="#+id/norme"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</TableRow>
<TableRow // the three fields are here
android:id="#+id/tableRow7"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/tvprix"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/od_price"
style="#style/BazarStyleLabel" />
<EditText
android:id="#+id/prix"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="number"/>
<TextView
android:id="#+id/monnaie"
android:layout_height="wrap_content"
style="#style/BazarStyleLabel" />
<TextView
android:id="#+id/barre"
android:layout_height="wrap_content"
android:text="/"
style="#style/BazarStyleLabel" />
<EditText
android:id="#+id/fatra"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="text"/>
</TableRow>
<TableRow
android:id="#+id/tableRow5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_span="5"
android:gravity="center">
<Button
android:id="#+id/ok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_ok" />
</TableRow>
</TableLayout>
Try this code for table row
<TableRow
android:id="#+id/tableRow7"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/tvprix"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/od_price"
style="#style/BazarStyleLabel" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:orientation="horizontal" >
<EditText
android:id="#+id/prix"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="number" />
<TextView
android:id="#+id/monnaie"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="bbbb" />
<TextView
android:id="#+id/barre"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="/" />
<EditText
android:id="#+id/fatra"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="text" />
</LinearLayout>
</TableRow>
I have the following layout in my application
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TableRow>
<TextView
android:text="Username"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:id="#+id/username"
android:inputType="textEmailAddress"
/>
</TableRow>
<TableRow>
<TextView
android:text="Password"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:id="#+id/password"
android:inputType="textPassword"
/>
</TableRow>
<!-- ADDED NEW -->
<TableRow
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/savePwd"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:text="Save Password (In encrypted clear text)"
/>
</LinearLayout>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<TextView
android:text="Please Log In"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/message_login"/>
</TableRow>
<TableRow android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="bottom|center">
<Button
android:id="#+id/btn_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Log In"/>
</TableRow>
</TableLayout>
The problem here is around the EditTexts. The TextViews expand to match the LinearLayout. This is not what I would like. I would like it to behave like the button below it (which doesn't expand the TextViews). Here is a screenshot...
Before...
After
Since you are using weights on the Edit Texts, remove the android:layout_width="wrap_content" from the Edit Texts, and the weight will be extended how you like.
This Rows for the TextViews/EditText should look like this instead....
<TableRow>
<TextView
android:text="Password"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.0" />
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2.0"
android:id="#+id/password"
android:inputType="textPassword"
/>
</TableRow>
// try this
<?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:padding="5dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp">
<TextView
android:text="Username"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="#+id/username"
android:layout_marginLeft="5dp"
android:inputType="textEmailAddress"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp">
<TextView
android:text="Password"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="#+id/password"
android:layout_marginLeft="5dp"
android:inputType="textPassword"/>
</LinearLayout>
<!-- ADDED NEW -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/savePwd"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="5dp"
android:text="Save Password (In encrypted clear text)"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp">
<TextView
android:text="Please Log In"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/message_login"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:gravity="bottom|center"
android:layout_marginTop="5dp"
android:layout_weight="1">
<Button
android:id="#+id/btn_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Log In"/>
</LinearLayout>
</LinearLayout>
I am using Datepicker in Android. I get a tottaly Bizzare UI in Jellybean.
Here is the Layout Code:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout01"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp" >
<TextView
android:id="#+id/textView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/stores"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Spinner
android:id="#+id/spinner_sales_store"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp" >
<TextView
android:id="#+id/textView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/products"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Spinner
android:id="#+id/spinner_sales_product"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp" >
<TextView
android:id="#+id/textView3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/quantities"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Spinner
android:id="#+id/spinner_sales_quantity"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</TableRow>
<TableRow
android:id="#+id/tableRow4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp" >
<TextView
android:id="#+id/textView4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Price"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView_sales_price"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="------"
android:textAppearance="?android:attr/textAppearanceMedium" />
</TableRow>
<TableRow
android:id="#+id/tableRow5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp" >
<TextView
android:id="#+id/textView5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="No of Items"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/txt_sales_num"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</TableRow>
<TableRow
android:id="#+id/tableRow6a"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp" >
<TextView
android:id="#+id/textView6a"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Order Date"
android:textAppearance="?android:attr/textAppearanceMedium" />
</TableRow>
<TableRow
android:id="#+id/tableRow6b"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp" >
<android.widget.DatePicker
android:id="#+id/dpicker_sales_Order_date"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:id="#+id/tableRow7a"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="2dp">
<TextView
android:id="#+id/textView7"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Issue Date"
android:textAppearance="?android:attr/textAppearanceMedium" />
</TableRow>
<TableRow
android:id="#+id/tableRow7b"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp" >
<android.widget.DatePicker
android:id="#+id/dpicker_sales_Issue_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right" />
</TableRow>
<TableRow
android:id="#+id/tableRow8"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<Button
android:id="#+id/btn_sales_save"
style="#style/ButtonStyle_menu"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:background="#drawable/custom_button"
android:text="#string/save"
android:onClick="saveClicked_Sales" />
</TableRow>
</TableLayout>
</ScrollView>
Have you experienced any such Issues?
Is there any way to show just the UI as in GingerBread?
There is no code in the Activity. Just the xml codings.
Add android:calendarViewShown="false" to your <DatePicker> element to suppress the calendar, if you do not wish to make room for it.