Thanks in advance for any help. I am very new to Android.
Here's my problem. I am using a TableLayout to display editable fields. There are about twenty rows to display.
The rows overflow the screen on smaller devices. I need the View to allow the user to scroll up and down. What am I missing?
Tried wrapping the TableLayout in a ScrollView, didn't work.
put your TableLayout inside ScrollView
<?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
android:id="#+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</TableRow>
</TableLayout>
</ScrollView>
Try something like 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:orientation="vertical" >
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TableLayout
android:id="#+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/editText2"
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" >
<EditText
android:id="#+id/editText4"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:id="#+id/tableRow5"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/editText5"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:id="#+id/tableRow6"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/editText6"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:id="#+id/tableRow7"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/editText7"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:id="#+id/tableRow8"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/editText8"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:id="#+id/tableRow9"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/editText9"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:id="#+id/tableRow10"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/editText10"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:id="#+id/tableRow11"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/editText11"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<requestFocus />
</EditText>
</TableRow>
<TableRow
android:id="#+id/tableRow12"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/editText12"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:id="#+id/tableRow13"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/editText13"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:id="#+id/tableRow14"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/editText14"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:id="#+id/tableRow15"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/editText15"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
</TableLayout>
</ScrollView>
but how about using a listView instead?
Related
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 am trying a linearlayout scrollable in android app. I need it this way.
when user swipes up, Box 1 can move out of screen and box 2 should be fixed at top of the screen and box 3 is a scrollable box. How to implement this? I think image helps you to understand.
<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"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<ScrollView
android:id="#+id/scroller"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >
<TableLayout
android:id="#+id/tableLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="26dp" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Row1" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Row2" />
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/editText3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Row3" />
</TableRow>
<TableRow
android:id="#+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/editText4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tableLayout1"
android:layout_alignRight="#+id/tableLayout1"
android:layout_below="#+id/tableLayout1"
android:ems="10"
android:text="Row4" />
</TableRow>
</TableLayout>
</ScrollView>
<TableLayout
android:id="#+id/tableLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tableLayout2"
android:layout_centerVertical="true"
android:layout_marginLeft="49dp" >
<TableRow
android:id="#+id/tableRow5"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/editText5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tableLayout1"
android:layout_centerVertical="true"
android:ems="10"
android:text="Row5" />
</TableRow>
</TableLayout>
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tableLayout3"
android:layout_below="#+id/tableLayout2"
android:layout_marginTop="25dp" >
<TableRow
android:id="#+id/tableRow6"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/editText6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Row6" >
<requestFocus />
</EditText>
</TableRow>
<TableRow
android:id="#+id/tableRow7"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/editText7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Row7" />
</TableRow>
<TableRow
android:id="#+id/tableRow8"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/editText8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Row8" />
</TableRow>
<TableRow
android:id="#+id/tableRow9"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/editText9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Row9" />
</TableRow>
</TableLayout>
</RelativeLayout>
You can do this by using ListView where the section header remains at the top. See this for an example: https://github.com/JimiSmith/PinnedHeaderListView
I actually need Pinned header and found this more useful.
This github project is actually working(Only few tweaks in code). #rahulritesh link also helped me. But this is more understandable for me.
https://github.com/beworker/pinned-section-listview/
How to design the following as shown in the picture:
my xml structure is:
<Root>
<other design>
<need to design as in picture>
</Root>
the picture is :
that is the text should appear in left and right alignment.
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="HOUR"
android:textColor="#C0C0C0" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="$1.80"
android:textColor="#6686A8" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="DAY"
android:textColor="#C0C0C0" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="$10.00"
android:textColor="#6686A8" />
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="WEEK"
android:textColor="#C0C0C0" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="$35.00"
android:textColor="#6686A8" />
</TableRow>
<TableRow
android:id="#+id/tableRow4"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="MONTH"
android:textColor="#C0C0C0" />
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="$105.00"
android:textColor="#6686A8" />
</TableRow>
</TableLayout>
You can use TableLayout to achieve that kind of layout.
I am android beginner. I want to create login page design (using user name password) retrieve data from a sqlite database. Can you help me? For example like Gmail etc
You can use following layout:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_gravity="fill_horizontal"
android:fillViewport="true"
android:scrollbarStyle="insideInset"
android:scrollbars="horizontal|vertical" >
<FrameLayout
android:id="#+id/frameLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/white" >
<TableLayout
android:id="#+id/tablelayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TableRow
android:id="#+id/tablerow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center" >
<TableLayout
android:id="#+id/tablerow1_tablelayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TableRow
android:id="#+id/frameLayout1_tblLayout1_tableRow1_tbllayout1_tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/frameLayout1_tblLayout1_tableRow1_tbllayout1_tableRow2_txtviewspace"
android:layout_width="30px"
android:layout_height="100px" />
</TableRow>
</TableLayout>
</TableRow>
<TableRow
android:id="#+id/tablerow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center" >
<TableLayout
android:id="#+id/tablerow2_tablelayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TableRow
android:id="#+id/tablerow1_tablelayout1_tablerow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/tablerow1_tablelayout1_tablerow1_viewspace1"
android:layout_width="30px"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/tablerow1_tablelayout1_tablerow1_u_id"
android:layout_width="150px"
android:layout_height="wrap_content"
android:text="User Name: "
android:textColor="#color/black"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="#+id/tablerow1_tablelayout1_tablerow1_viewspace2"
android:layout_width="30px"
android:layout_height="wrap_content" />
<EditText
android:id="#+id/loginedituid"
android:layout_width="200px"
android:layout_height="wrap_content"
android:inputType="text"
android:maxLength="10"
android:singleLine="true" />
</TableRow>
<TableRow
android:id="#+id/tablerow2_tablelayout1_tablerow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/tablerow2_tablelayout1_tablerow1_viewspace1"
android:layout_width="30px"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/tablerow2_tablelayout1_tablerow1_pasword"
android:layout_width="150px"
android:layout_height="wrap_content"
android:text="Password: "
android:textColor="#color/black"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="#+id/tablerow2_tablelayout1_tablerow1_viewspace2"
android:layout_width="30px"
android:layout_height="wrap_content" />
<EditText
android:id="#+id/editpswrd"
android:layout_width="200px"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:maxLength="10"
android:singleLine="true" />
<TextView
android:id="#+id/tablerow2_tablelayout1_tablerow1_viewspace3"
android:layout_width="30px"
android:layout_height="wrap_content" />
</TableRow>
</TableLayout>
</TableRow>
<TableRow
android:id="#+id/tablerow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center" >
<TableLayout
android:id="#+id/tablerow3_tablelayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TableRow
android:id="#+id/frameLayout1_tblLayout1_tableRow1_tbllayout1_tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/frameLayout1_tblLayout1_tableRow1_tbllayout1_tableRow2_txtviewspace"
android:layout_width="10px"
android:layout_height="30px" />
</TableRow>
<TableRow
android:id="#+id/frameLayout1_tblLayout1_tableRow1_tbllayout1_tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/frameLayout1_tblLayout1_tableRow1_tbllayout1_tableRow2_txtviewspace"
android:layout_width="30px"
android:layout_height="30px" />
</TableRow>
<TableRow android:id="#+id/frameLayout1_tblLayout1_tableRow1_tbllayout1_tableRow2" >
<TableRow
android:id="#+id/tablerow3_tablelayout1_tablerow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/tablerow3_tablelayout1_tablerow1_viewspace1"
android:layout_width="130px"
android:layout_height="30px" />
<Button
android:id="#+id/btnlogin"
android:layout_width="150px"
android:layout_height="60px"
android:text="LOGIN"
android:textStyle="bold" />
<TextView
android:id="#+id/tablerow3_tablelayout1_tablerow1_viewspace1"
android:layout_width="130px"
android:layout_height="30px" />
<Button
android:id="#+id/btnexit"
android:layout_width="150px"
android:layout_height="60px"
android:text="EXIT"
android:textStyle="bold" />
</TableRow>
</TableRow>
</TableLayout>
</TableRow>
</TableLayout>
</FrameLayout>
This will be your login design.