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>
Related
I am currently using TableLayout inside ScrollView and Multiple ListView inside TableRows for getting following results.
With following XML
<?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" >
<include layout="#layout/progress_bar" />
<ScrollView
android:id="#+id/sv"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TableRow
android:id="#+id/tr_lbl_topSongs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/app_orange"
android:padding="5dp" >
<TextView
android:id="#+id/tv_lbl_topSongs"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Top Songs"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/app_white" />
</TableRow>
<TableRow
android:id="#+id/tr_content_topSongs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" >
<ListView
android:id="#+id/lv_topSongs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:listSelector="#android:color/transparent" >
</ListView>
</TableRow>
<TableRow
android:id="#+id/tr_viewMore_topSongs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:background="#color/app_offwhite"
android:gravity="center_horizontal|center_vertical"
android:padding="5dp" >
<TextView
android:id="#+id/tv_viewMore_topSongs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal|center_vertical"
android:text="View More"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/app_gray" />
</TableRow>
<TableRow
android:id="#+id/tr_lbl_topVideos"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/app_orange"
android:padding="5dp" >
<TextView
android:id="#+id/tv_lbl_topVideos"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Top Videos"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/app_white" />
</TableRow>
<TableRow
android:id="#+id/tr_content_topVideos"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" >
<ListView
android:id="#+id/lv_topVideos"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:listSelector="#android:color/transparent" >
</ListView>
</TableRow>
<TableRow
android:id="#+id/tr_viewMore_topVideos"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:background="#color/app_offwhite"
android:gravity="center_horizontal|center_vertical"
android:padding="5dp" >
<TextView
android:id="#+id/tv_viewMore_topVideos"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal|center_vertical"
android:text="View More"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/app_gray" />
</TableRow>
<TableRow
android:id="#+id/tr_lbl_topRingtones"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/app_orange"
android:padding="5dp" >
<TextView
android:id="#+id/tv_lbl_topRingtones"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Top Ringtones"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/app_white" />
</TableRow>
<TableRow
android:id="#+id/tr_content_topRingtones"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" >
<ListView
android:id="#+id/lv_topRingtones"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:listSelector="#android:color/transparent" >
</ListView>
</TableRow>
<TableRow
android:id="#+id/tr_viewMore_topRingtones"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_weight="1"
android:background="#color/app_offwhite"
android:gravity="center_horizontal|center_vertical"
android:padding="5dp" >
<TextView
android:id="#+id/tv_viewMore_topRingtones"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal|center_vertical"
android:text="View More"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/app_gray" />
</TableRow>
</TableLayout>
</ScrollView>
</LinearLayout>
I done hacks on ListViews for Scroll issues created by Conflict of ScrollView and ListView. Now I realized that this is creating some mess with NavigationDrawer I want to shift to single ListView Approach. Is it possible? Any Example? Thanks in Advance.
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 my layout file:
<?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="fill_parent"
android:background="#drawable/background"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/linearlayout01"
android:layout_width="300dp"
android:layout_height="45dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="52dp"
android:orientation="vertical" >
</LinearLayout>
<Button
android:id="#+id/Btn"
android:background="#drawable/close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="-2dp"
android:layout_marginTop="10dp">
</Button>
<TableLayout
android:id="#+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:shrinkColumns="1"
android:stretchColumns="0"
android:layout_marginTop="15dp" >
<TableRow android:weightSum="2" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="end"
android:text="#string/HostName"
android:textColor="#000000"
android:textStyle="bold" />
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_weight="0"
android:textColor="#000000"
android:textStyle="bold" />
</TableRow>
<TableRow android:weightSum="2"
android:layout_marginTop="30dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="end"
android:text="#string/programname"
android:textColor="#000000"
android:textStyle="bold" />
<TextView
android:id="#+id/programname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0"
android:textColor="#000000"
android:textStyle="bold" />
</TableRow>
<TableRow android:weightSum="2"
android:layout_marginTop="30dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="end"
android:text="#string/Date"
android:textColor="#000000"
android:textStyle="bold" />
<TextView
android:id="#+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0"
android:textColor="#000000"
android:textStyle="bold" />
</TableRow>
<TableRow android:layout_marginTop="20dp"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"
>
<SeekBar
android:id="#+id/seekBar1"
android:layout_width="500dp"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/mainlayout"
android:layout_marginLeft="-260dp"
android:layout_marginRight="0dp"
android:layout_marginTop="8dp" />
</TableRow>
</TableLayout>
</LinearLayout>
and I got the following output:
Update:
But my required output should be:
| HostName: text123 |
| PName: text3 |
| Date: text6 |
Could any one help?
String, try with this. I have attached the output too. I don't get any irregular text-alignments as I have shown in the below pic.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/linearlayout01"
android:layout_width="300dp"
android:layout_height="45dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="52dp"
android:orientation="vertical" >
</LinearLayout>
<Button
android:id="#+id/Btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="-2dp"
android:layout_marginTop="10dp"
android:text="close">
</Button>
<TableLayout
android:id="#+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:shrinkColumns="*"
android:stretchColumns="*"
android:layout_marginTop="15dp" >
<TableRow
android:id="#+id/tableRow1"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:weightSum="2">
<TextView
android:id="#+id/TextView04"
android:text="Date"
android:layout_width="0dp"
android:layout_weight="1"></TextView>
<TextView
android:id="#+id/TextView04"
android:text="text123"
android:textStyle="bold"
android:layout_width="0dp"
android:layout_weight="1"></TextView>
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:weightSum="2">
<TextView
android:id="#+id/TextView04"
android:text="Date"
android:layout_width="0dp"
android:layout_weight="1"></TextView>
<TextView
android:id="#+id/TextView04"
android:text="text123"
android:textStyle="bold"
android:layout_width="0dp"
android:layout_weight="1"></TextView>
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:weightSum="2">
<TextView
android:id="#+id/TextView04"
android:text="Date"
android:layout_width="0dp"
android:layout_weight="1"></TextView>
<TextView
android:id="#+id/TextView04"
android:text="text123"
android:textStyle="bold"
android:layout_width="0dp"
android:layout_weight="1"></TextView>
</TableRow>
<TableRow
android:id="#+id/tableRow4"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:weightSum="2">
<TextView
android:id="#+id/TextView04"
android:text="Date"
android:layout_width="0dp"
android:layout_weight="1"></TextView>
<TextView
android:id="#+id/TextView04"
android:text="text123"
android:textStyle="bold"
android:layout_width="0dp"
android:layout_weight="1"></TextView>
</TableRow>
<TableRow
android:id="#+id/tableRow5"
android:layout_height="wrap_content"
android:layout_width="match_parent">
<SeekBar
android:id="#+id/seekBar1"
android:layout_width="500dp"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/mainlayout"
android:layout_marginLeft="-260dp"
android:layout_marginRight="0dp"
android:layout_marginTop="8dp" />
</TableRow>
</TableLayout>
</LinearLayout>
Output:
Post back if you have any issues.
Better try this ..
<RelativeLayout 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" >
<LinearLayout
android:id="#+id/rows"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableLayout
android:id="#+id/key"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp" >
<TableRow
android:id="#+id/row1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="HName" />
<TextView
android:id="#+id/txt2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="HostName" />
</TableRow>
<TableRow
android:id="#+id/row2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp" >
<TextView
android:id="#+id/txt3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="PName" />
<TextView
android:id="#+id/txt4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="ProgramName" />
</TableRow>
<TableRow
android:id="#+id/row3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp" >
<TextView
android:id="#+id/txt5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Date" />
<TextView
android:id="#+id/txt6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Todays Date" />
</TableRow>
</TableLayout>
</LinearLayout>
</RelativeLayout>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:weightSum="2" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="end"
android:text="Date"
android:textColor="#ffffff"
android:textStyle="bold" />
<TextView
android:id="#+id/date"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:text="text123"
android:textColor="#ffffff"
android:textStyle="bold" />
</TableRow>
You must give android:layout_weight for both TextView in a TableRow equally . I think it will solve your issue
EDIT :
I just give simple modifications in your xml code
<?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="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/linearlayout01"
android:layout_width="300dp"
android:layout_height="45dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="52dp"
android:orientation="vertical" >
</LinearLayout>
<Button
android:id="#+id/Btn"
android:background="#drawable/close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="-2dp"
android:layout_marginTop="10dp">
</Button>
<TableLayout
android:id="#+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:shrinkColumns="1"
android:stretchColumns="0"
android:layout_marginTop="15dp" >
<TableRow android:weightSum="2" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="end"
android:text="HostName"
android:textColor="#ffffff"
android:textStyle="bold" />
<TextView
android:id="#+id/name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_weight="1"
android:text="HostName"
android:textColor="#ffffff"
android:textStyle="bold" />
</TableRow>
<TableRow android:weightSum="2"
android:layout_marginTop="30dp"
>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="end"
android:text=" programname"
android:textColor="#ffffff"
android:textStyle="bold" />
<TextView
android:id="#+id/date"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text=" programname"
android:layout_weight="1"
android:textColor="#ffffff"
android:textStyle="bold" />
</TableRow>
<TableRow android:weightSum="2"
android:layout_marginTop="30dp"
>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="end"
android:text=" Date"
android:textColor="#ffffff"
android:textStyle="bold" />
<TextView
android:id="#+id/date"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text=" date"
android:layout_weight="1"
android:textColor="#ffffff"
android:textStyle="bold" />
</TableRow>
<TableRow android:layout_marginTop="20dp"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"
>
<SeekBar
android:id="#+id/seekBar1"
android:layout_width="500dp"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/mainlayout"
android:layout_marginLeft="-260dp"
android:layout_marginRight="0dp"
android:layout_marginTop="8dp" />
</TableRow>
</TableLayout>
</LinearLayout>
Screen shot after my modification
Is this you want ??
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.
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>