Buttonbar won't stick to bottom of screen - android

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>

Related

Make FrameLayout element scrollable

I am working on adapting an app which was designed for a larger vertical screen dimension (1200px) to a device with a smaller size (vertical=800px). I've managed to get things displaying properly by editing the layout XML files--except for one thing. As you can see, the crossword puzzle is cut off at the bottom. Its original dimensions in the layout were 570x570px. At that size, the lower part of the puzzle ended up peeking out from behind the keyboard.
After resizing both the keyboard and the clue drop-down at the top of the screen so they work properly, I'm left with a vertical space of 390px for the puzzle. Absent any other ideas, I've been trying to implement scrolling in that FrameLayout, following several examples such as Scrollable FrameLayout.
I can't seem to get it to work. My knowledge of layout is sketchy. Can anyone suggest a solution or a different approach?
(the puzzle layout on the screen is given in line 6)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:gravity="bottom|center" android:orientation="vertical" android:background="#color/root_background" android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<FrameLayout android:gravity="top|center" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1.0">
<FrameLayout android:gravity="top|center" android:orientation="vertical" android:id="#id/field_container" android:paddingTop="160.0px" android:layout_width="600.0px" android:layout_height="wrap_content">
<com.encore.crossword.view.CrosswordView android:layout_gravity="top|center" android:id="#id/crosswordView" android:layout_width="570.0px" android:layout_height="390.0px" />
<LinearLayout android:gravity="center" android:id="#id/difficulty_layout" android:paddingTop="146.0px" android:visibility="invisible" android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:layout_gravity="center" android:orientation="vertical" android:background="#drawable/c_dialog_box" android:paddingLeft="30.0px" android:paddingTop="30.0px" android:paddingRight="30.0px" android:paddingBottom="20.0px" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:textAppearance="#style/DialogHeader" android:gravity="center" android:id="#id/TextViewGameOver" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Game Difficulty" />
<RadioGroup android:gravity="left|center" android:orientation="vertical" android:id="#id/RadioGroupDifficulty" android:paddingTop="6.0px" android:paddingBottom="6.0px" android:layout_width="fill_parent" android:layout_height="wrap_content">
<RadioButton android:textAppearance="#style/ButtonTextMain" android:textColor="#color/button_radio" android:id="#id/RadioButtonEasy" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="false" android:button="#drawable/sudoku_radio_button" android:text="#string/easy" android:width="160.0px" />
<RadioButton android:textAppearance="#style/ButtonTextMain" android:textColor="#color/button_radio" android:id="#id/RadioButtonMedium" android:layout_width="wrap_content" android:layout_height="wrap_content" android:button="#drawable/sudoku_radio_button" android:text="#string/medium" android:width="160.0px" />
<RadioButton android:textAppearance="#style/ButtonTextMain" android:textColor="#color/button_radio" android:id="#id/RadioButtonHard" android:layout_width="wrap_content" android:layout_height="wrap_content" android:button="#drawable/sudoku_radio_button" android:text="#string/hard" android:width="160.0px" />
<RadioButton android:textAppearance="#style/ButtonTextMain" android:textColor="#color/button_radio" android:id="#id/RadioButtonExtreme" android:layout_width="wrap_content" android:layout_height="wrap_content" android:button="#drawable/sudoku_radio_button" android:text="#string/themeless" android:width="160.0px" />
</RadioGroup>
</LinearLayout>
</LinearLayout>
</FrameLayout>
<LinearLayout android:gravity="top|center" android:orientation="vertical" android:id="#id/clue_container" android:background="#drawable/cross_top_dialog_box" android:paddingLeft="5.0px" android:paddingRight="5.0px" android:layout_width="fill_parent" android:layout_height="wrap_content">
<LinearLayout android:gravity="top|center" android:orientation="vertical" android:id="#id/mini_clue_container" android:paddingLeft="5.0px" android:paddingRight="5.0px" android:visibility="visible" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1.0">
<LinearLayout android:id="#id/ClueTop1" android:layout_width="fill_parent" android:layout_height="wrap_content">
<TextView android:textAppearance="#style/ClueInfoText" android:id="#id/TextViewClueWordNumber1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="" android:layout_weight="1.0" />
<TextView android:textAppearance="#style/ClueInfoText" android:gravity="right" android:id="#id/TextViewClueWordLength1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="" android:layout_weight="1.0" />
</LinearLayout>
<TextView android:textAppearance="#style/ClueText" android:id="#id/TextViewClue1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="10.0px" android:text="" android:lines="2" />
<LinearLayout android:id="#id/ClueTop2" android:layout_width="fill_parent" android:layout_height="wrap_content">
<TextView android:textAppearance="#style/ClueInfoText" android:id="#id/TextViewClueWordNumber2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="" android:layout_weight="1.0" />
<TextView android:textAppearance="#style/ClueInfoText" android:gravity="right" android:id="#id/TextViewClueWordLength2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="" android:layout_weight="1.0" />
</LinearLayout>
<TextView android:textAppearance="#style/ClueText" android:id="#id/TextViewClue2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="10.0px" android:text="" android:lines="2" />
</LinearLayout>
<LinearLayout android:gravity="top|center" android:orientation="vertical" android:id="#id/big_clue_container" android:paddingLeft="0.0px" android:paddingRight="0.0px" android:visibility="gone" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1.0">
<TextView android:textAppearance="#style/ClueTextBold" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="10.0px" android:text="ACROSS" />
<LinearLayout android:gravity="top|center" android:orientation="vertical" android:id="#id/big_clue_across_container" android:background="#drawable/c_dialog_box" android:paddingTop="17.0px" android:paddingBottom="17.0px" android:layout_width="fill_parent" android:layout_height="200.0px">
<ListView android:scrollbarStyle="outsideOverlay" android:id="#id/big_clue_across_list" android:paddingLeft="5.0px" android:layout_width="fill_parent" android:layout_height="wrap_content" />
</LinearLayout>
<TextView android:textAppearance="#style/ClueTextBold" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="10.0px" android:text="DOWN" />
<LinearLayout android:gravity="top|center" android:orientation="vertical" android:id="#id/big_clue_down_container" android:background="#drawable/c_dialog_box" android:paddingTop="17.0px" android:paddingBottom="17.0px" android:layout_width="fill_parent" android:layout_height="200.0px">
<ListView android:id="#id/big_clue_down_list" android:paddingLeft="5.0px" android:layout_width="fill_parent" android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<ImageView android:id="#id/ClueContainerArrow" android:background="#drawable/cross_down_arrow" android:layout_width="30.0px" android:layout_height="20.0px" android:layout_marginBottom="10.0px" android:layout_weight="1.0" />
</LinearLayout>
<LinearLayout android:gravity="bottom" android:layout_gravity="bottom|left|center" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent">
<include android:id="#id/bottom_layout" android:layout_width="fill_parent" android:layout_height="160.0px" layout="#layout/bottom_layout" />
</LinearLayout>
<include android:id="#id/bottom_menu" android:layout_width="fill_parent" android:layout_height="fill_parent" layout="#layout/bottom_menu" />
</FrameLayout>
<LinearLayout android:gravity="center" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="50.0dip">
<LinearLayout android:gravity="center" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1.0">
<Button android:textAppearance="#style/ButtonText" android:textColor="#color/solid_white" android:id="#id/GameButton" android:background="#drawable/btn_footer" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="2.0dip" android:layout_marginRight="0.0dip" android:text="Game" android:layout_weight="1.0" />
<ImageView android:id="#id/ImageView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="#drawable/footer_line_divider" />
<Button android:textAppearance="#style/ButtonText" android:textColor="#color/solid_white" android:id="#id/LastWordButton" android:background="#drawable/btn_footer" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="0.0dip" android:layout_marginRight="0.0dip" android:text="Prev Word" android:layout_weight="1.0" />
<ImageView android:id="#id/ImageView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="#drawable/footer_line_divider" />
<Button android:textAppearance="#style/ButtonText" android:textColor="#color/solid_white" android:id="#id/NextWordButton" android:background="#drawable/btn_footer" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="2.0dip" android:layout_marginRight="0.0dip" android:text="Next Word" android:layout_weight="1.0" />
<ImageView android:id="#id/ImageView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="#drawable/footer_line_divider" />
<Button android:textAppearance="#style/ButtonText" android:textColor="#color/solid_white" android:id="#id/KeyboardButtonHint" android:background="#drawable/btn_footer" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="0.0dip" android:layout_marginRight="0.0dip" android:text="Hint" android:layout_weight="1.0" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

LinearLayout align text to center view with drawableLeft

I am not able to align the image to textview.
What I want it to look like:
What it actually looks like:
Please ignore the background color, image size. The issue is related to aligning the image with the text view.
I have tried the following code:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableStart="#drawable/icon_checkin"
android:gravity="center"
android:text="#string/check_in"
android:drawablePadding="-20sp"
style="#style/roboto4F4F4Flight21"
/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableLeft="#drawable/icon_checkout"
android:text="#string/check_out"
style="#style/roboto4F4F4Flight21"
android:gravity="center"
/>
</LinearLayout>
Note: I have used android:drawablePadding="-20sp" but without success.
Also tried:
<TableLayout
android:id="#+id/linear_today_attendance"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns = "*"
>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableStart="#drawable/icon_checkin"
android:gravity="center"
android:text="#string/check_in"
android:drawablePadding="-20sp"
style="#style/roboto4F4F4Flight21"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/icon_checkout"
android:text="#string/check_out"
style="#style/roboto4F4F4Flight21"
android:gravity="center"
/>
</TableRow>
</TableLayout>
Not the cleanest option, but it should work:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableStart="#drawable/icon_checkin"
android:text="#string/check_in"
style="#style/roboto4F4F4Flight21" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableStart="#drawable/icon_checkout"
android:text="#string/check_out"
style="#style/roboto4F4F4Flight21" />
</LinearLayout>
</LinearLayout>
Wrapping the TextView in a LinearLayout worked for me. Give it a shot.
// FYI, all columns are stretched using android:stretchColumns="*"
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/ic_add_black_24dp"/>
</LinearLayout>
// and again same thing for the next item
<LinearLayout...>
<TextView.../>
</LinearLayout>
</TableRow>

Layout invisible, button up on him

(i have put the code at the end of my post)
i would like to make a hidden menu.
I don't know if i take the good way.
I have some button visible, some invisible button and at the an another visible button.
One of the button in first layout have to set visible the hidden buttons.
I would like to have the last button just after the first bunch.
But like i have put invisible the Layout so i have an empty space.
I would like when i pressed the button for set visible that the last button go down.
I hope you will understand want i want to do and what i have done.
<?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"
android:background="#drawable/fond"
>
<ImageView
android:id="#+id/imageView1"
android:contentDescription="#string/desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/top"
android:layout_gravity="top"
android:adjustViewBounds="true"
/>
<LinearLayout
android:layout_below="#+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#drawable/fond2"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="3"
>
<Button
android:id="#+id/button_garçon"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="#string/Bg"
android:background="#drawable/button_purple"
android:layout_weight="1"
android:textColor="#ffffff"
android:onClick="actionGarçon"
/>
<Button
android:id="#+id/button_mixte"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="#string/Bm"
android:background="#drawable/button_purple"
android:layout_weight="1"
android:textColor="#ffffff"
android:onClick="actionMixte"
/>
<Button
android:id="#+id/button_fille"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="#string/Bf"
android:background="#drawable/button_purple"
android:layout_weight="1"
android:textColor="#ffffff"
android:onClick="actionFille"
/>
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="1"
>
<Button
android:id="#+id/button_param"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Bp"
android:background="#drawable/button_green"
android:layout_weight="1"
android:textColor="#ffffff"
android:onClick="actionParametre"
/>
</LinearLayout>
<!-- invisible -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="invisible"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/Tq"
android:textColor="#000000"
/>
<EditText android:id="#+id/edit_message"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="#string/Emc"
android:singleLine="true"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/Tpre"
android:textColor="#000000"
/>
<EditText android:id="#+id/edit_message"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="#string/Epre"
android:singleLine="true"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/Tsuf"
android:textColor="#000000"
/>
<EditText
android:id="#+id/edit_message"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="#string/Esuf"
android:singleLine="true"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/Tl"
android:textColor="#000000"
/>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100"
>
<Button android:id="#+id/button_court"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Blc"
android:layout_weight="25"
android:background="#drawable/button_purple"
android:textColor="#ffffff"
android:onClick="actionCourt"
/>
<Button android:id="#+id/button_moyen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Blm"
android:layout_weight="25"
android:background="#drawable/button_purple"
android:textColor="#ffffff"
android:onClick="actionMoyen"
/>
<Button android:id="#+id/button_long"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Bll"
android:layout_weight="25"
android:background="#drawable/button_purple"
android:textColor="#ffffff"
android:onClick="actionLong"
/>
<Button android:id="#+id/button_tous"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Blt"
android:layout_weight="25"
android:background="#drawable/button_purple"
android:textColor="#ffffff"
android:onClick="actionTous"
android:state_pressed="true"
/>
</LinearLayout>
<Button android:id="#+id/button_orig"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/Bo"
android:background="#drawable/button_purple"
android:textColor="#ffffff"
android:onClick="actionOrigine"
/>
</LinearLayout>
<!-- /invisible -->
<Button android:id="#+id/button_recher"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/Br"
android:background="#drawable/button_green"
android:textColor="#ffffff"
android:onClick="actionRecherche"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Thanks in advance.
If I understand correctly you want to use android:visibility="gone" so that what ever you set to "gone" does not occupy any space on the layout.
Basically, instead of android:visibility="invisible" you should use android:visibility="gone"
See if that works.

Android:Footer with Linear Layout comes up when Soft Key Board is open

My app contains header,edittext,listview and footer
It works fine...but when soft keyboard is open for edittext my footer comes up.
I had also set android:windowSoftInputMode="adjustPan" in manifest.
my layout is as below
<?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:background="#drawable/middle_bg"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/header1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<include
android:id="#+id/header2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
layout="#layout/header" />
</RelativeLayout>
<TableLayout
android:id="#+id/tbllayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/header1"
>
<TableRow
android:layout_gravity="left"
android:background="#drawable/tit_bg" >
<TextView
android:id="#+id/lbltit"
android:layout_gravity="center_vertical"
android:layout_weight="2"
android:gravity="center"
android:text="Registered Websites"
android:textSize="20dp"
android:textStyle="bold" />
<Button
android:id="#+id/btnAddNewRege"
android:layout_gravity="center_vertical"
android:layout_weight="3"
android:background="#drawable/plus"
android:gravity="left" />
</TableRow>
<TableRow android:layout_width="fill_parent" >
<View
android:id="#+id/vwhr1"
android:layout_width="fill_parent"
android:layout_height="10dip"
android:layout_span="2" />
</TableRow>
<TableRow>
<EditText
android:id="#+id/txtSearch"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="#drawable/roundedtextview"
android:hint="Search"
android:textSize="13dp"
android:width="280sp"
/>
<Button
android:id="#+id/btnSearchMain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#drawable/search"
android:gravity="center" />
</TableRow>
<TableRow android:layout_width="fill_parent" >
<View
android:id="#+id/vwhr"
android:layout_width="fill_parent"
android:layout_height="10dip"
android:layout_span="2" />
</TableRow>
</TableLayout>
<LinearLayout
android:id="#+id/tblftr"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:isScrollContainer="true"
>
<TableLayout
android:id="#+id/btnpanel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:stretchColumns="*" >
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/black"
>
<Button
android:id="#+id/btnSetting"
android:layout_weight="1"
android:background="#drawable/settings"
android:width="40dp" />
<Button
android:id="#+id/btnAboutUs"
android:background="#drawable/about_us"
android:width="100dp" />
<Button
android:id="#+id/btnFeedback"
android:background="#drawable/feedback"
android:width="100dp" />
</TableRow>
<TableRow>
<include
android:id="#+id/include1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
layout="#layout/footer" />
</TableRow>
</TableLayout>
</LinearLayout>
<ListView
android:id="#+id/lst"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#id/tblftr"
android:layout_below="#id/tbllayout"
android:cacheColorHint="#android:color/transparent"
android:layout_centerHorizontal="true" >
</ListView>
</RelativeLayout>
pls guide
Thanks & Regards
Mita
You could try and put your RelativeLayout in a ScrollView. This might not worked as intended if the ListView doesn't fill the screen since you would have to declare layout_width="wrap_content" for your RelativeLayout inside the ScrollView and that would bring your footer right bellow the ListView.
Try it and see if it fits your model.

Making linearlayouts stay at bottom of screen in android

I am making an android application that uses these views:
(Root) - LinearLayout
(Child of root) - ListView + 3 other linearlayouts beneeth that listview. But once i add to many items to the listview, the layouts are being placed outside of the screen. Which i don't want to. How can i make this happen? So that all of the three linearlayouts stay on the screen, at the bottom??? Please help and thanks in advance!
My screen XML code:
<?xml version="1.0" encoding="utf-8"?>
LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/background"
android:orientation="vertical" >
<TextView
android:id="#+id/NotesWelcomeTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/NotesWelcomeText" />
<ListView
android:id="#+android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</ListView
<LinearLayout
android:id="#+id/DeleteAllItemsFromListViewLinearLayout"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:visibility="invisible" >
<Button
android:id="#+id/CancelButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Cancel" />
<Button
android:id="#+id/DeleteAllButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Delete" />
</LinearLayout>
<LinearLayout
android:id="#+id/DeleteItemFromListViewLinearLayout"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:visibility="invisible" >
<Button
android:id="#+id/CancelButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Cancel" />
<Button
android:id="#+id/DeleteButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Delete" />
</LinearLayout>
<LinearLayout
android:id="#+id/AddItemToListViewLinearLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone" >
<EditText
android:id="#+id/AddItemToListViewEditText"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_weight="1" >
</EditText>
<Button
android:id="#+id/AddItemToListViewButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/Add" />
</LinearLayout>
</LinearLayout>
Try this, you'll have to add the string references and background again, I removed them so I wouldn't have errors
<?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">
<TextView android:id="#+id/NotesWelcomeTextView"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="NotesWelcomeText" />
<ListView android:id="#+android:id/list" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_above="#+id/AddItemToListViewLinearLayout"
android:layout_below="#+id/NotesWelcomeTextView">
</ListView>
<LinearLayout android:id="#+id/DeleteAllItemsFromListViewLinearLayout"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_weight="1" android:visibility="invisible"
android:layout_alignParentBottom="true">
<Button android:id="#+id/CancelButton2" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Cancel" />
<Button android:id="#+id/DeleteAllButton" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Delete" />
</LinearLayout>
<LinearLayout android:id="#+id/DeleteItemFromListViewLinearLayout"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_weight="1" android:visibility="invisible"
android:layout_alignParentBottom="true">
<Button android:id="#+id/CancelButton" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Cancel" />
<Button android:id="#+id/DeleteButton" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Delete" />
</LinearLayout>
<LinearLayout android:id="#+id/AddItemToListViewLinearLayout"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:visibility="gone" android:layout_alignParentBottom="true">
<EditText android:id="#+id/AddItemToListViewEditText"
android:layout_width="250dp" android:layout_height="wrap_content"
android:layout_weight="1">
</EditText>
<Button android:id="#+id/AddItemToListViewButton"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:text="Add" />
</LinearLayout>
Give your ListView a weight of 0 and set its height to 0. This will tell the ListView to only take up the space that is not use by other views.
<ListView ...
android:layout_weight="0"
android:layout_height="0"
...
/>

Categories

Resources