How to make the last TableRow visible? - android

Picture of the android interface: http://tinypic.com/view.php?pic=avht6w&s=6
As seen in the picture above I want a small borders at the bottom and top of the white listView. The problem is, as I set the tableRow to be android:paddingBottom="20dp" the border never gets displayed at the bottom. It seems like, if the listviews height is big enough, nothing else after it will get displayed (See code example below to understand).
I have tested some different approaches to solve the problem, one is setting the paddingBottom attribute in the next TableRow (the borders tableRow) but it will only work if the listView's height is exact of the screens height and not to big.
Why do I set the listView's height to a fixed number like 415dp? Well, it is due to another problem I do not know how to solve. If I for example set the listViews height to fill_parent the background will only cover the number of items in the list. I always want the lists background to be filled down to 20dp from the bottom of the interface.
If anyone has some ideas how I can managed to display the border at the bottom and always have the lists background visible, even if it is not filled with items, please post your ideas! /thanx alot!
<?xml version="1.0" encoding="utf-8"?>
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#drawable/orginalbild"
android:gravity="center|top"
android:stretchColumns="1"
android:weightSum="1.0"
android:fillViewport="true">
<TableRow
android:background="#000000"
>
<TextView
android:layout_marginTop="0.15dp"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#999999"
android:layout_weight="1">
</TextView>
</TableRow>
<TableRow
android:background="#999999"
>
<TextView
android:background="#999999"
android:id="#+id/show_task_feedback_title"
android:layout_width="0dip"
android:layout_height="28dp"
android:layout_weight="0.8"
android:text="#string/LatestFeedbackTitle"
android:textColor="#ffffff"
android:textSize="17dp"
android:shadowColor="#FFFFFF"
android:layout_marginBottom="0.15dp"
android:textAppearance="?android:attr/textAppearanceMedium">
</TextView>
<TextView
android:layout_width="0dip"
android:layout_height="28dp"
android:layout_gravity="center"
android:layout_weight="0.08" >
</TextView>
<Button
android:id="#+id/latest_feedback_help_button"
android:layout_width="0dip"
android:layout_height="28dp"
android:layout_gravity="center"
android:background="#drawable/help_button"
android:layout_weight="0.12"
android:layout_marginBottom="0.15dp"
/>
</TableRow>
<TableRow
android:background="#212421">
<TextView
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#ffffff"
android:layout_marginTop="0.15dp"
android:layout_weight="1">
</TextView>
</TableRow>
<TableRow>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.25" />
</TableRow>
<TableRow
android:paddingLeft="24dp"
android:paddingRight="24dp"> <--------THE BLACK BRODER AT THE TOP OF THE LISTVIEW
<TextView
android:background="#000000"
android:layout_width="0dip"
android:layout_height="0.5dp"
android:layout_weight="1" >
</TextView>
</TableRow>
<TableRow
android:paddingLeft="24dp"
android:paddingRight="24dp"
android:paddingBottom="20dp" <------(paddingBottom attribute which causes the problem)
>
<ListView
android:background="#ffffff"
android:id="#+id/bookmarks_list"
android:layout_width="0dip"
android:layout_height="415dp"
android:gravity="left"
android:layout_weight="1"
/>
</TableRow>
<TableRow> <---THE BLACK BRODER AT THE BOTTOM OF THE LISTVIEW(not being displayed)
<TextView
android:background="#000000"
android:layout_width="0dip"
android:layout_height="0.5dp"
android:layout_weight="1" >
</TextView>
</TableRow>
</TableLayout>

See if this helps.
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/orginalbild"
android:fillViewport="true"
android:gravity="center|top"
android:orientation="vertical"
android:stretchColumns="1"
android:weightSum="1.0" >
<TableRow android:background="#000000" >
<TextView
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_marginTop="0.15dp"
android:layout_weight="1"
android:background="#999999" >
</TextView>
</TableRow>
<TableRow android:background="#999999" >
<TextView
android:id="#+id/show_task_feedback_title"
android:layout_width="0dip"
android:layout_height="28dp"
android:layout_marginBottom="0.15dp"
android:layout_weight="0.8"
android:background="#999999"
android:shadowColor="#FFFFFF"
android:text="#string/LatestFeedbackTitle"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#ffffff"
android:textSize="17dp" >
</TextView>
<TextView
android:layout_width="0dip"
android:layout_height="28dp"
android:layout_gravity="center"
android:layout_weight="0.08" >
</TextView>
<Button
android:id="#+id/latest_feedback_help_button"
android:layout_width="0dip"
android:layout_height="28dp"
android:layout_gravity="center"
android:layout_marginBottom="0.15dp"
android:layout_weight="0.12"
android:background="#drawable/help_button" />
</TableRow>
<TableRow android:background="#212421" >
<TextView
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_marginTop="0.15dp"
android:layout_weight="1"
android:background="#ffffff" >
</TextView>
</TableRow>
<TableRow>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.25" />
</TableRow>
<TableRow
android:paddingTop="0.5dp"
android:paddingBottom="0.5dp"
android:background="#000000"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:layout_marginBottom="20dp"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ListView
android:id="#+id/bookmarks_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#ffffff"
android:gravity="left"
android:entries="#array/listitems" />
</TableRow>
</TableLayout>

Related

TextView alignment in the TableRow

There are two TableRows in the TableLayout, and each TableRow contains two TextViews:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" >
<TextView
android:id="#+id/textTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/textTitle"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="63dp"
android:layout_marginRight="10dp" >
<TextView
android:id="#+id/textHall"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/textPrice"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp" />
</TableRow>
</TableLayout>
If textHall contains a short Word, textTitle (Some Text) located at the correct position:
But if textHall contains a long Second Word, before textTitle (Some Text) appears a large indentation:
What is the reason?
Thanks.
You should give weight for your layouts and rows. I adapted your code. Here is the one that should be.
<TableRow
android:id="#+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:weightSum="2" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:orientation="horizontal" >
<TextView
android:id="#+id/textTime"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="10:30" />
<TextView
android:id="#+id/textTitle"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="left"
android:layout_marginLeft="10dp"
android:text="Some Text" />
</LinearLayout>
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="63dp"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:weightSum="2" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:orientation="horizontal" >
<TextView
android:id="#+id/textHall"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Some Word" />
<TextView
android:id="#+id/textPrice"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:text="200" />
</LinearLayout>
</TableRow>
You can put any margin value for your second row as you wish.
Hope this may help.
Your textHall and textTime both fall into same column and the width of that column is set to the width of textHall(as this is having more width) as a result your textTime textview's width is increasing when you increase text in textHall.

ScrollView a TableLayout inside a TabHost

I am trying to scroll a TableLayout that is nested inside a Tab. I can scroll the Table as intended but the problem is that the Table when scrolls up, it shows up behind the Tab as it scrolls.
I want to make just the Table part of the Layout to scroll.
At the end there is a RelativeLayout which serves as a legend(Key Guide) of the information that I will show dynamically in the form of rows inside the Table. SO it needs to be at the bottom of the screen and should not scroll like the table itself. But in this code everything below the Tab scrolls up (except the RelativeLayout)
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:baselineAligned="false"
android:orientation="vertical">
//Fixed On Screen
<TabHost
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</TabWidget>
//Fixed On Screen
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="4dp" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="fill_horizontal"
android:padding="4dp" >
<TextView
style="#android:style/TextAppearance.Medium"
android:layout_weight="1"
android:text="#string/start"
android:textStyle="bold"
android:typeface="serif" />
<TextView
style="#android:style/TextAppearance.Medium"
android:layout_weight="1"
android:text="#string/end"
android:textStyle="bold"
android:typeface="serif" />
<TextView
style="#android:style/TextAppearance.Medium"
android:layout_weight="1"
android:paddingLeft="5dp"
android:text="#string/effect"
android:textStyle="bold"
android:typeface="serif" />
</TableRow>
</TableLayout>
</LinearLayout>
//Scroll this content inside the Tab ONLY
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_horizontal" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TableLayout
android:id="#+id/Tab1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="4dp"
android:stretchColumns="*" >
</TableLayout>
<TableLayout
android:id="#+id/Tab2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="4dp"
android:stretchColumns="*" >
</TableLayout>
</LinearLayout>
</ScrollView>
</FrameLayout>
</TabHost>
//Fixed On Screen at the very bottom so the area between this and Tab is what scrolls
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_weight="1"
android:background="#color/green"
android:padding="5dp"
android:text="#string/excellent"
android:textColor="#FFFFFF" />
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_weight="1"
android:background="#color/light_blue"
android:padding="5dp"
android:text="Good"
android:textColor="#FFFFFF" />
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_weight="1"
android:background="#color/dark_gray"
android:padding="5dp"
android:text="#string/normal"
android:textColor="#FFFFFF" />
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_weight="1"
android:background="#color/red"
android:padding="5dp"
android:text="Bad"
android:textColor="#FFFFFF" />
</TableRow>
</RelativeLayout>
In short, I want the following to be fixed on screen:
The Tab
The First TableLayout
The Last RelativeLayout
And want only the middle FrameLayout/TableLayout to Scroll. This layout will be filled with rows dynamically.
I have a feeling that it is as simple as maybe a wrap_content or fill_parent maybe. But can't seem to figure this out.
Thanks!

LinearLayout doesn't fill tablerow even width fill_parent is called

I have a linearLayout inside a tableRow, this linearLayout contains a chart that i would like to display for my app.
I read some thread saying that the child of the tableRow not need to specify its width and height, so I did it, but the chart is not displayed. If I specify the linearLayout to be width=fill_parent and height=200dp, then the linearlyLayout is only fill 1/3 of the tableRow.
<?xml version="1.0" encoding="UTF-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_horizontal" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Record"
android:textSize="18dp"
android:textStyle="bold"
android:typeface="serif" >
</TextView>
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_horizontal" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:text="Name:"
android:textStyle="bold"
android:typeface="serif" >
</TextView>
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.7"
android:ems="10"
android:singleLine="true" />
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_horizontal" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:text="Date:"
android:textStyle="bold"
android:typeface="serif" >
</TextView>
<TextView
android:id="#+id/editRecordDate"
android:layout_width="0dp"
android:layout_weight="0.7"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:id="#+id/tableRow9"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="#+id/soundaomplitude_graphViewLinearLayout"
android:paddingTop="4dip" > //if I specify nothing then nothing is displayed, if I set width = fill_parent and height = 200dp, then only 1/3 of the space is occupied
</LinearLayout>
</TableRow>
<TableRow
android:id="#+id/tableRow10"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<Button
android:id="#+id/saveEditRecord"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".3"
android:text="Save" />
<Button
android:id="#+id/deleteEditRecord"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".3"
android:text="Delete" />
<Button
android:id="#+id/cancelEditRecord"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight=".3"
android:text="Cancel" />
</TableRow>
</TableLayout>
</ScrollView>
I found out just set the weight = 1(or any number) for the linearLayout
<LinearLayout
android:id="#+id/soundaomplitude_graphViewLinearLayout"
android:layout_width="0dp"
android:layout_height="200dp"
android:layout_weight="1"
android:paddingTop="4dip" />
It seems that a TableRow acts as a LinearLayout, hence nesting one right inside a TableRow seems redundant. In Eclipse also, it says, that it is "useless". Therefore, you can just include your view (any view) directly inside the TableRow, instead of the LinearLayout. If it is not showing, then, there is probably some other problems.
Read again on how TableLayout manages its content. Specifically note that it disregards the layout_width of child views.

Buttonbar won't stick to bottom of screen

I'm trying to put the buttonbar I've created on the bottom of each screen. I've succeeded for the first screen fairly easy.
Now I've tried to put it other screens, but it seems that it can't stick to the bottom of the screen. When I look in the hiearchyviewer, it looks like the RelativeLayout that's wrapped araound my layout and buttonbar, isn't filling the whole screen, though, its height is set to fill parent.
Can anyone help me by pointing out where I'm going wrong?
This is the XML I use:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="vertical">
<TableLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" android:padding="5pt" android:id="#+id/table"
android:stretchColumns="1">
<TableRow>
<TextView android:text="#string/Arbeiderbediende"
android:id="#+id/txtArbeiderBediende" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
<TableRow android:gravity="center">
<RadioGroup android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="horizontal"
android:id="#+id/group1">
<RadioButton style="#style/RadioButton"
android:layout_width="wrap_content" android:id="#+id/rbArbeider"
android:text="#string/Arbeider" android:layout_height="wrap_content"
android:paddingLeft="18pt" />
<RadioButton style="#style/RadioButton"
android:layout_width="wrap_content" android:id="#+id/rbBediende"
android:text="#string/Bediende" android:layout_height="wrap_content"
android:layout_marginLeft="20pt" android:paddingLeft="18pt" />
</RadioGroup>
</TableRow>
<TableRow android:gravity="center" android:paddingTop="5dip">
<TextView android:text="#string/OverzichtFuncties"
android:id="#+id/txtFuncties" android:layout_width="0dip"
android:layout_weight="1" android:layout_height="wrap_content" />
<Spinner android:layout_height="wrap_content" style="Spinner"
android:layout_width="0dip" android:layout_weight="2"
android:id="#+id/cmbFuncties" />
</TableRow>
<TableRow android:gravity="center" android:paddingTop="5dip">
<TextView android:text="#string/Regio" android:id="#+id/txtRegio"
android:layout_width="0dip" android:layout_weight="1"
android:layout_height="wrap_content" />
<Spinner android:layout_height="wrap_content"
android:layout_width="0dip" android:layout_weight="2" android:id="#+id/cmbRegio" />
</TableRow>
<TableRow android:gravity="center" android:paddingTop="5dip">
<TextView android:text="#string/Opleiding" android:id="#+id/txtOpleidingsniveau"
android:layout_width="0dip" android:layout_weight="1"
android:layout_height="wrap_content" />
<Spinner android:layout_height="wrap_content"
android:layout_width="0dip" android:layout_weight="2"
android:id="#+id/cmbOpleidingsniveau" />
</TableRow>
<Button android:text="#string/VindJobButton" android:id="#+id/btnFindJob"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_marginTop="10dip" />
</TableLayout>
<stage.accent.Toolbar android:layout_width="fill_parent"
android:layout_height="70dip" android:layout_alignParentBottom="true"
android:layout_below="#+id/table" />
</RelativeLayout>
This is the result I achieved and the result I want to get
In case you want your buttonbar to be always visible at the bottom of the screen and not scroll with the content, you might want to switch your RelativeLayout and ScrollView tags, and move your buttonbar to be the first child of your RelativeLayout, the ScrollView to be the second:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical">
<stage.accent.Toolbar android:id="id/buttonBar" android:layout_width="fill_parent"
android:layout_height="70dip" android:layout_alignParentBottom="true" />
<ScrollView android:layout_above="#+id/buttonBar"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<TableLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" android:padding="5pt" android:id="#+id/table"
android:stretchColumns="1">
<TableRow>
<TextView android:text="#string/Arbeiderbediende"
android:id="#+id/txtArbeiderBediende" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
<TableRow android:gravity="center">
<RadioGroup android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="horizontal"
android:id="#+id/group1">
<RadioButton style="#style/RadioButton"
android:layout_width="wrap_content" android:id="#+id/rbArbeider"
android:text="#string/Arbeider" android:layout_height="wrap_content"
android:paddingLeft="18pt" />
<RadioButton style="#style/RadioButton"
android:layout_width="wrap_content" android:id="#+id/rbBediende"
android:text="#string/Bediende" android:layout_height="wrap_content"
android:layout_marginLeft="20pt" android:paddingLeft="18pt" />
</RadioGroup>
</TableRow>
<TableRow android:gravity="center" android:paddingTop="5dip">
<TextView android:text="#string/OverzichtFuncties"
android:id="#+id/txtFuncties" android:layout_width="0dip"
android:layout_weight="1" android:layout_height="wrap_content" />
<Spinner android:layout_height="wrap_content" style="Spinner"
android:layout_width="0dip" android:layout_weight="2"
android:id="#+id/cmbFuncties" />
</TableRow>
<TableRow android:gravity="center" android:paddingTop="5dip">
<TextView android:text="#string/Regio" android:id="#+id/txtRegio"
android:layout_width="0dip" android:layout_weight="1"
android:layout_height="wrap_content" />
<Spinner android:layout_height="wrap_content"
android:layout_width="0dip" android:layout_weight="2" android:id="#+id/cmbRegio" />
</TableRow>
<TableRow android:gravity="center" android:paddingTop="5dip">
<TextView android:text="#string/Opleiding" android:id="#+id/txtOpleidingsniveau"
android:layout_width="0dip" android:layout_weight="1"
android:layout_height="wrap_content" />
<Spinner android:layout_height="wrap_content"
android:layout_width="0dip" android:layout_weight="2"
android:id="#+id/cmbOpleidingsniveau" />
</TableRow>
<Button android:text="#string/VindJobButton" android:id="#+id/btnFindJob"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_marginTop="10dip" />
</TableLayout>
</ScrollView>
</RelativeLayout>
This way you'll be able to achieve what you want:
and
The button bar will be always at the bottom of your screen.
And by scrolling the content, you'll be able to see the last bit of it too, it won't be hidden behind the buttonbar:
I still suggests dont use ScrollView here is an example how you can show the ButtonBar at the bottom
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="wrap_content">
<RelativeLayout
android:id="#+id/headerlayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
>
<Button android:id="#+id/amap_back_btn" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_alignParentTop="true"
android:layout_alignParentLeft="true" android:text="Back">
</Button>
<TextView android:id="#+id/amap_txt"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="" android:layout_centerVertical="true"
android:layout_centerHorizontal="true">
</TextView>
<ImageButton android:id="#+id/amap_action_btn"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:src="#drawable/icon_menu_action"
android:layout_alignParentTop="true" android:layout_alignParentRight="true">
</ImageButton>
</RelativeLayout>
//What ever widgets you wants to add
<LinearLayout
android:id="#+id/bottomlayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:orientation="horizontal"
>
<ImageButton android:id="#+id/map_refresh_btn"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:src="#drawable/icon_refresh"
android:gravity="center"
>
</ImageButton>
<Button android:id="#+id/map_log_btn" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Log"
android:gravity="center">
</Button>
<Button android:id="#+id/map_map_btn" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Map"
android:gravity="center"
>
</Button>
</LinearLayout>
</RelativeLayout>
that is all this is the most robust solution.
If you find it useful dont forget to mark it as an answer.
Please take one main linear layout
above scroll view and after ending
scroll view please set your bottom
bar..
It would be also my suggetion.
LinearLayout is the main view.
Within it
Another LinearLayout (layout_height=0dp and layout_weight = 1) *ll_container*
and you tabbar
Within *ll_container* place
a scrollview (layout_height=0dp and layout_weight = 1) with tablelayout
and the button
Probably for explanation. With layout_height=0dp and layout_weight = 1 you give your layouts the whole free place remaining after placing your tabbar and then after placing your button
UPD
<?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:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical">
<ScrollView android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1">
<TableLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" android:padding="5pt" android:id="#+id/table"
android:stretchColumns="1">
<TableRow>
<TextView android:text="#string/Arbeiderbediende"
android:id="#+id/txtArbeiderBediende" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
<TableRow android:gravity="center">
<RadioGroup android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="horizontal"
android:id="#+id/group1">
<RadioButton style="#style/RadioButton"
android:layout_width="wrap_content" android:id="#+id/rbArbeider"
android:text="#string/Arbeider" android:layout_height="wrap_content"
android:paddingLeft="18pt" />
<RadioButton style="#style/RadioButton"
android:layout_width="wrap_content" android:id="#+id/rbBediende"
android:text="#string/Bediende" android:layout_height="wrap_content"
android:layout_marginLeft="20pt" android:paddingLeft="18pt" />
</RadioGroup>
</TableRow>
<TableRow android:gravity="center" android:paddingTop="5dip">
<TextView android:text="#string/OverzichtFuncties"
android:id="#+id/txtFuncties" android:layout_width="0dip"
android:layout_weight="1" android:layout_height="wrap_content" />
<Spinner android:layout_height="wrap_content" style="Spinner"
android:layout_width="0dip" android:layout_weight="2"
android:id="#+id/cmbFuncties" />
</TableRow>
<TableRow android:gravity="center" android:paddingTop="5dip">
<TextView android:text="#string/Regio" android:id="#+id/txtRegio"
android:layout_width="0dip" android:layout_weight="1"
android:layout_height="wrap_content" />
<Spinner android:layout_height="wrap_content"
android:layout_width="0dip" android:layout_weight="2" android:id="#+id/cmbRegio" />
</TableRow>
<TableRow android:gravity="center" android:paddingTop="5dip">
<TextView android:text="#string/Opleiding" android:id="#+id/txtOpleidingsniveau"
android:layout_width="0dip" android:layout_weight="1"
android:layout_height="wrap_content" />
<Spinner android:layout_height="wrap_content"
android:layout_width="0dip" android:layout_weight="2"
android:id="#+id/cmbOpleidingsniveau" />
</TableRow>
</TableLayout>
</ScrollView>
<Button android:text="#string/VindJobButton" android:id="#+id/btnFindJob"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_marginTop="10dip" />
</LinearLayout>
<stage.accent.Toolbar android:layout_width="fill_parent"
android:layout_height="70dip" android:layout_alignParentBottom="true"
android:layout_below="#+id/table" />
</LinearLayout>

Android textview and Menu

i have a textview and a Menu , the textview is currently showing at the bottom of the screen and when menu pressed ,currently the menu hide the textview ,but i want the textview automatically move upwords so that everybody can see
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:orientation="vertical"
android:background="#drawable/android_bg"
android:layout_height="fill_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="#drawable/navigationbar">
<TextView android:layout_width="wrap_content" android:layout_centerInParent="true"
android:id="#+id/banner_text"
android:layout_height="wrap_content" android:background="#drawable/bannertext_angies_list">></TextView>
<Button
android:layout_width="55dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:layout_height="35dp"
android:background="#drawable/sign_out_button_clicked_button"
android:id="#+id/signout"/>
</RelativeLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:layout_width="fill_parent"
android:orientation="vertical"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp">
<TableRow
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="10dp">
<TextView
android:visibility="gone"
android:textColor="#000000"
android:text="Thank you, your report has been"
android:textSize="16sp"
android:textStyle="bold"
android:layout_width="260dp"
android:layout_height="fill_parent"
android:id="#+id/Thanks_to_submission1"/>
</TableRow>
<TableRow
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:visibility="gone"
android:paddingLeft="70dp"
android:textColor="#000000"
android:text="submitted successfuly!"
android:textSize="16sp"
android:textStyle="bold"
android:layout_width="260dp"
android:layout_height="fill_parent"
android:id="#+id/Thanks_to_submission2"/>
</TableRow>
<TableRow
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="50dp">
<Button
android:layout_width="260dp"
android:layout_height="fill_parent"
android:background="#drawable/submitbutton"
android:id="#+id/submitreport_providertype_button"/>
</TableRow>
<TableRow
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="10dp">
<Button
android:layout_width="260dp"
android:layout_height="fill_parent"
android:background="#drawable/searchlist_button"
android:id="#+id/search_list_button"/>
</TableRow>
<TableRow
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="10dp">
<Button
android:layout_width="260dp"
android:layout_height="fill_parent"
android:background="#drawable/bigdeal_button"
android:id="#+id/big_deal_button"/>
</TableRow>
</TableLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_marginTop="50dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="14sp"
android:textStyle="bold"
android:onClick="true"
android:textColor="#000000"
android:text="Or visit our website at" />
<TextView
android:layout_width="wrap_content"
android:layout_height="40dp"
android:id="#+id/link"
android:gravity="center_vertical"
android:autoLink="web"
android:linksClickable="true"
android:layout_gravity="center"
android:textSize="14sp"
android:textStyle="bold"
android:onClick="true"
android:textColor="#000000"
android:text="#string/link" />
</LinearLayout>
<TextView
android:visibility="invisible"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="14dp"
android:text="Or visit our website at" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
That's not really supported by Android, and it's by design. The idea is that you can use the full screen for your UI, and the menu takes up part of the space when you need to select it. You don't want to worry about text views and other things while the menu is up. This is better than the iPhone, where you permanently have to give up screen space for menu items. If something is really important, then move it away from the bottom of the screen.
If you're really bent on moving stuff around, you could intercept Activity.onPrepareOptionsMenu and move things around in your UI, although the function wasn't really meant for that purpose. Then matching call is onOptionsMenuClosed.

Categories

Resources