I want to do something like this:
Button 1 centered in the top left part of the screen
Button 2 in the top right
Button 3 in the bottom left
and three or four buttons in the bottom right.
I'm new so I can't post a picture.
I tried different layouts but zero results.
Thanks for the help.
What you want is a RelativeLayout: http://developer.android.com/reference/android/widget/RelativeLayout.html
Something along the lines of:
<RelativeLayout>
<Button android:layout_alignParentTop="true" android:layout_alignParentLeft="true" />
<Button android:layout_alignParentTop="true" android:layout_alignParentRight="true" />
<Button android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" />
</RelativeLayout>
From that you should be able to figure out the rest. I suggest reading up on RelativeLayout and its alignment parameters
EDIT- After you explained in the comments, try something like:
<LinearLayout android:orientation="vertical">
<LinearLayout android:orientation="horizontal" android:layout_weight=".5">
<LinearLayout android:layout_weight=".5">
<Button android:layout_gravity="center" />
</LinearLayout>
<LinearLayout android:layout_weight=".5">
<Button android:layout_gravity="center" />
</LinearLayout>
</LinearLayout>
<LinearLayout android:orientation="horizontal" android:layout_weight=".5">
<LinearLayout android:layout_weight=".5">
<Button android:layout_gravity="center" />
</LinearLayout>
<LinearLayout android:layout_weight=".5">
<Button android:layout_gravity="center" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
That will fill your screen with 4 equally-sized 'blocks' and have a button positioned directly in the center of each one.
After some work I made it with a TableLayout and some LinearLayouts.
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/TableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="4" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="2"
android:gravity="center" >
<LinearLayout
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 1" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 2" />
</LinearLayout>
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="2"
android:gravity="center" >
<LinearLayout
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 3" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:gravity="center"
android:orientation="vertical" >
<Button
android:id="#+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 4" />
</LinearLayout>
</TableRow>
There was a question posted like 5 min ago about this.
How to properly distribute 4 buttons on an android layout
I don't want to be rude, but you should try harder.
Related
I tried this code but text on these buttons are messed in my phone; although it is fine in Nexus 5 emulator....! How can I put these 4 buttons one line dynamically so that they can look same on any screen size...
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:weightSum="8" >
<Button
android:id="#+id/bback"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="Back" />
<Button
android:id="#+id/bforward"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="Forward" />
<Button
android:id="#+id/brefresh"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="Refresh" />
<Button
android:id="#+id/bclear"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="Clear History" />
</LinearLayout>
set android:layout_width to 0dp instead of fill_parent for all buttons.
Try this, it will keep the button size as same in any device , also spread the buttons with equal distance on any device,
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp" >
<LinearLayout
android:id="#+id/1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<Button
android:id="#+id/bback"
android:layout_width="40dp"
android:layout_height="40dp"
android:text="Back"
android:layout_gravity="center" />
</LinearLayout>
//same as layout 2,3,4 and respective button with in it
</LinearLayout>
EDITTEED
Please try with this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="5"
android:orientation="vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp"
>
<Button
android:id="#+id/bback"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:text="Back" />
<Button
android:id="#+id/bforward"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:text="Forward" />
<Button
android:id="#+id/brefresh"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:text="Refresh" />
<Button
android:id="#+id/bclear"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:text="Clear History" />
</LinearLayout>
</LinearLayout>
I need to line buttons up horizontally, however, my buttons are appearing vertically. They are all stacked up on top of each other.. do you know how I can do this horizontally?
<TableLayout
android:id="#+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="88dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:orientation="horizontal" >
<Button android:layout_weight="1" />
<Button android:layout_weight="1" />
<Button android:layout_weight="1" />
<Button android:layout_weight="1" />
</TableLayout>
Using Linear layout you can easily represent your button in horizontally.
<LinearLayout
android:id="#+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<Button android:layout_weight="1" />
<Button android:layout_weight="1" />
<Button android:layout_weight="1" />
<Button android:layout_weight="1" />
</LinearLayout>
You have not identified a TableRow for your TableLayout. Imagine how a table is created, row's go horizontally and columns go vertically.
Fixing your code would look something like this
<TableLayout
android:id="#+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="88dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true" >
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button android:layout_weight="1" />
<Button android:layout_weight="1" />
<Button android:layout_weight="1" />
<Button android:layout_weight="1" />
</TableRow>
</TableLayout>
Alternatively, to make things easier, I would recommend using a LinearLayout with the orientation set to horizontal.
Use a linearlayout as follows:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#646464"
android:gravity="center|center_vertical"
android:paddingBottom="5dp"
android:paddingTop="5dp" >
<Button
android:id="#+id/inner_artist_profile"
android:layout_width="60dp"
android:layout_height="25dp"
android:text="Profile"
android:textColor="#AEAEAE"
android:background="#drawable/sub_nav_left" />
<Button
android:id="#+id/inner_artist_news"
android:layout_width="60dp"
android:layout_height="25dp"
android:text="News"
android:textColor="#AEAEAE"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/inner_artist_profile"
android:background="#drawable/sub_nav_middle" />
<Button
android:id="#+id/inner_artist_events"
android:layout_width="60dp"
android:layout_height="25dp"
android:text="Events"
android:textColor="#AEAEAE"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/inner_artist_news"
android:background="#drawable/sub_nav_middle" />
<Button
android:id="#+id/inner_artist_videos"
android:layout_width="60dp"
android:layout_height="25dp"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/inner_artist_events"
android:background="#drawable/sub_nav_middle"
android:text="Videos"
android:textColor="#AEAEAE" />
<Button
android:id="#+id/inner_artist_albums"
android:layout_width="60dp"
android:layout_height="25dp"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/inner_artist_videos"
android:background="#drawable/sub_nav_right"
android:text="Albums"
android:textColor="#AEAEAE" />
</RelativeLayout>
this is from a working project modify id's according to need
Instead of a TableLayout, I think you should use a LinearLayout with a WeightSum. To distribute the widths of the 4 buttons evenly, set their widths to 0 and their weight to 1. Then set the weight sum of the LinearLayout to 4 (the number of buttons). Like this:
<LinearLayout
android:id="#+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="88dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:orientation="horizontal"
android:weightSum="4">
<Button
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1" />
<Button
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1" />
<Button
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1" />
<Button
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1" />
</LinearLayout>
There are many ways to do this.Please check following is one of the way
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="4" >
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
Add TableRow to TableLayout and here is the working code
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="88dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:orientation="horizontal" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_horizontal" >
<Button android:layout_weight="1" />
<Button android:layout_weight="1" />
<Button android:layout_weight="1" />
<Button android:layout_weight="1" />
</TableRow>
</TableLayout>
Or encapsulate the Button objects within a TableRow tag e.g
<TableRow>
<Button></Button>
</TableRow>
In my screen I am having 3 buttons and in next row below those buttons I am having 3 names (name corresponding to those buttons) but my problem is that when ever name changes then size of buttons also changes but I do want to fix the size of buttons here is my code please help me
<TableLayout android:background="#drawable/toptab"
android:layout_width="fill_parent" android:id="#+id/tableLayout"
android:layout_height="wrap_content"
android:stretchColumns="1" android:gravity="center_vertical"
android:layout_alignParentBottom="true">
<TableRow>
<ImageButton android:id="#+id/btnPrev" android:background="#drawable/imgPrev"
android:layout_marginLeft="5dp"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<ImageButton android:id="#+id/btnRefresh"
android:layout_gravity="center" android:background="#drawable/refreshbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<ImageButton android:id="#+id/btnNext"
android:background="#drawable/imgNext"
android:layout_width="5dp"
android:layout_height="20dp"
android:layout_marginRight="5dp" />
</TableRow>
<TableRow >
<TextView android:id="#+id/prev" android:text="Hk" android:layout_marginLeft="5dp" />
<TextView android:id="#+id/refresh" android:text="Refresh" android:layout_gravity="center" />
<TextView android:id="#+id/next" android:text="RS" android:layout_marginRight="5dp" />
</TableRow>
</TableLayout>
If you want to avoid fixing button size, then I would recommend using different layout than TableLayout, maybe RelativeLayout and TextViews with property alignBaseline or LinearLayout with weight properties could do the trick.
You should use linearlayout instead of table layout and use Weight property for aligning buttons and text view in equal dimensions, so here if you write more text in text view , button size will not increase. Also you can add more buttons in same manner. Below is the XML file and screen shot.
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<LinearLayout
android:id="#+id/linearLayout4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" android:layout_weight="1" android:gravity="center_horizontal">
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextViewTextTextViewTextTextView" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" android:layout_weight="1" android:gravity="center_horizontal">
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" android:layout_weight="1" android:gravity="center_horizontal">
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
</LinearLayout>
I have a problems with my layout_margin. I want to make my layout look like that:
(with "a" is margin)
My problems is, when i build my layout in other screen size, it look like that:
How can i make it beautiful with different screen size? This is my layout:
<LinearLayout
android:id="#+id/footer_result_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal" >
<ImageView
android:id="#+id/btn_recommendtion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="#drawable/coodinate" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_marginTop="20dip"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal" >
<ImageView
android:id="#+id/btn_facebook"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_margin="5dip"
android:layout_weight="1"
android:adjustViewBounds="true"
android:src="#drawable/fb" />
<ImageView
android:id="#+id/btn_mixi"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_margin="5dip"
android:layout_weight="1"
android:adjustViewBounds="true"
android:src="#drawable/mixi" />
</LinearLayout>
</LinearLayout>
Try using a relative layout.
Here is an example using buttons. You can swap out the values of the buttons with your image views, and adjust your margins as needed. This should center the buttons, with the same margins on any screen.
<Button
android:id="#+id/btn_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:text="BUTTON 1"
android:layout_centerHorizontal="true"/>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_below="#+id/btn_1"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dip"
android:orientation="horizontal" >
<Button
android:id="#+id/btn_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:layout_margin="5dip"
android:text="BUTTON 2" />
<Button
android:id="#+id/btn_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:layout_margin="5dip"
android:text="BUTTON 3" />
</LinearLayout>
It looks like this:
You'll need to use RelativeLayout for that.
Center button1 with android:layout_alignParentTop="true" and align it in the parent top with android:layout_centerHorizontal="true and work from there.
The code:-
<?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">
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 1"
android:layout_margin="10dip"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"/>
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 2"
android:layout_margin="10dip"
android:layout_alignParentLeft="true"
android:layout_below="#+id/button1"/>
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 3"
android:layout_margin="10dip"
android:layout_alignParentRight="true"
android:layout_below="#+id/button1"/>
</RelativeLayout>
Considering the a=10
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>