TableLayout below Listview not displaying - android

I want to show a TableLayout below a Listview (where the the no. of items are dynamically added). I referred to a similar question before, but it didn't work for me. I am using android:layout_below to set the TableLayout below the Listview but it still doesn't work, I would appreciate anyone guiding me on how to do this.
Here is my code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.AppBarLayout>
<ListView
android:id="#+id/list"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:clipToPadding="false"
android:divider="#color/list_divider"
android:dividerHeight="10.0sp"
android:listSelector="#drawable/list_row_selector"
android:paddingBottom="100dip"
android:paddingTop="70dip" />
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/list"
android:layout_weight="1">
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Total Items"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="idvalue_text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp">
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Total Cost"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView21"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="idvalue_text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</TableRow>
</TableLayout>
</android.support.design.widget.CoordinatorLayout>

Okay. So as per our discussion in the comments section on taking a look at your code, it seems you want to have both the ListView and the TableLayout to have equal height (because you included layout_weight to both of them).
So in order to produce your desired output, do the following.
Use a RelativeLayout as the Parent Layout.
Add a LinearLayout with weightSum = 2 and orientation=vertical, and put the ListView and the TableLayout inside it, where both of their height = 0dp and the layout_weight = 1.
Here's a sample snippet for your reference:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="2">
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<TableLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="#id/list"
android:layout_weight="1">
</TableLayout>
</LinearLayout>
</RelativeLayout>
Doing so would result to something like this:
PS: This is just the display when checking the layout in the Android Studio preview, not when the code is running.

Related

How to move a LinearLayout to the right side of the toolbar

I am trying to add into the toolbar a TextView and a Spinner to implement language change from there. The problem it's that I added a LinearLayout to the toolbar but I cannot manage to move it to the right side so it won't get over the title of the activity, or to stay next to it.
Right now the LinearLayout is set like that (+ where i want it to be):
.xml code:
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay">
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/limba"
android:textColor="#color/white"
android:textSize="15sp"
android:layout_gravity="center"/>
<Spinner
android:layout_marginLeft="5dp"
android:id="#+id/spinner_limba"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
And the result it is :
I am trying to achieve something like :
I achieved that by setting a android:paddingLeft but that wont work on all the devices the same way, so I am looking for another solution.
I have tried adding gravity but it wasn't moving my layout.
add android:layout_gravity="right" in Linear layout.
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right">
</LinearLayout>
Wrap the LinearLayout with a RelativeLayout and provide
android:layout_alignParentRight="true"
property to LinearLayout.
Try this,
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.appbar.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="match_parent">
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test"
android:textSize="15sp"
android:layout_gravity="center"/>
<Spinner
android:layout_marginLeft="5dp"
android:id="#+id/spinner_limba"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</RelativeLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>

ScrollView not working within Coordinator and Relative layout

The following code display only 3 of 4 Editext within a ScrollView.
The problem is the last Editext which is overlapping the Button
Why ScrollView isn't working properly?
Or How avoid this overlaps?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
android:id="#+id/cl"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/bt_next">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways"
android:layout_alignParentTop="true">
<TextView
android:id="#+id/tv_activity_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#fff"
android:textSize="24sp"
android:text="#string/app_name"/>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:id="#+id/mysv">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="#+id/et_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Input 1"/>
<View android:layout_width="match_parent" android:layout_height="150dp" />
<EditText
android:id="#+id/et_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Input 2"/>
<View android:layout_width="match_parent" android:layout_height="150dp" />
<EditText
android:id="#+id/et_3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Input 3"/>
<View android:layout_width="match_parent" android:layout_height="150dp" />
<EditText
android:id="#+id/et_4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Input 4"/>
</LinearLayout>
</ScrollView>
</android.support.design.widget.CoordinatorLayout>
<Button
android:id="#+id/bt_next"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Next"/>
This is how looks like at the end of the scroll.
Your problem is not the ScrollView, your problem is the fact that you have the Button floating out by itself outside of the CoordinatorLayout.
If you're trying to get the content above the button, you could try adding alignToTopOf="#id/bt_next (I forget the exact name of the attribute, but you get the idea). Then the Coordinator should sit on top of the button.
If that's not what you're trying to do, post a screenshot of what you're trying to get to and a screenshot of what's broken now.
I've solved using Nestedlayout and a LinearLayout inside.
The key is keep in mind CoordinatorLayout works as a FrameLayout.
The only issue that I find is the toolbar is not hiding when I scroll.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
android:id="#+id/cl"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/bt_next"
android:layout_alignParentTop="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/mysv">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways">
<TextView
android:id="#+id/tv_activity_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#fff"
android:textSize="24sp"
android:text="#string/app_name"/>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="#+id/mysv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="#+id/et_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Input 1"/>
<View android:layout_width="match_parent" android:layout_height="150dp" />
<EditText
android:id="#+id/et_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Input 2"/>
<View android:layout_width="match_parent" android:layout_height="150dp" />
<EditText
android:id="#+id/et_3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Input 3"/>
<View android:layout_width="match_parent" android:layout_height="150dp" />
<EditText
android:id="#+id/et_4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Input 4"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
<Button
android:id="#+id/bt_next"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Next"/>
</RelativeLayout>

Android App UI Design : WhatsApp like Tabs

How can I change the width of single Tab in a TabLayout?
setting app:tabMode="scrollable" in xml layout will change width of all tab items. But I want to change the width of individual tab items, or to be specific, the first tab item.
A good example of what I am trying to do is the camera tab in WhatsApp's home screen. Width of that tab is just enough to show the icon.
How can I achieve the same result?
Below is my layout xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.example.myapplication.WolfApp">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="#dimen/appbar_padding_top"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="#style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="#+id/tabs"
app:tabMode="scrollable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabIndicatorColor="#ffffff">
</android.support.design.widget.TabLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="#dimen/fab_margin"
app:srcCompat="#android:drawable/ic_dialog_email" />
</android.support.design.widget.CoordinatorLayout>
Not the answer to your question, but, I just decompiled the WhatsApp apk, and found the layout file which I think is of the home screen,
here:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:id="#id/root_view" android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:whatsapp="http://schemas.android.com/apk/res-auto">
<FrameLayout android:id="#id/camera_frame" android:layout_width="fill_parent" android:layout_height="fill_parent" />
<LinearLayout android:orientation="vertical" android:fitsSystemWindows="true" android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout android:id="#id/call_notification" android:background="#drawable/call_duration_bar_background" android:paddingLeft="16.0dip" android:paddingTop="8.0dip" android:paddingRight="16.0dip" android:paddingBottom="8.0dip" android:layout_width="fill_parent" android:layout_height="wrap_content">
<TextView android:textSize="17.0sp" android:textColor="#android:color/white" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="#string/tap_to_return_to_call" android:layout_toLeftOf="#id/call_notification_timer" android:layout_alignParentLeft="true" />
<TextView android:textSize="16.0sp" android:textColor="#android:color/white" android:gravity="center_vertical" android:id="#id/call_notification_timer" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:textAllCaps="true" />
</RelativeLayout>
<FrameLayout android:layout_width="fill_parent" android:layout_height="fill_parent">
<FrameLayout android:id="#id/pager_holder" android:paddingTop="0.0dip" android:layout_width="fill_parent" android:layout_height="fill_parent">
<view android:id="#id/pager" android:layout_width="fill_parent" android:layout_height="fill_parent" class="com.whatsapp.HomeActivity$TabsPager" />
</FrameLayout>
<LinearLayout android:orientation="vertical" android:id="#id/header" android:background="?colorPrimary" android:layout_width="fill_parent" android:layout_height="wrap_content">
<include layout="#layout/toolbar" />
<com.whatsapp.HomePagerSlidingTabStrip android:id="#id/tabs" android:background="#color/primary" android:layout_width="fill_parent" android:layout_height="#dimen/tab_height" whatsapp:pstsIndicatorColor="#color/tab_indicator" whatsapp:pstsDividerColor="#android:color/transparent" whatsapp:pstsIndicatorHeight="3.0dip" whatsapp:pstsUnderlineHeight="1.0dip" whatsapp:pstsTabPaddingLeftRight="8.0dip" whatsapp:pstsShouldExpand="true" />
</LinearLayout>
<FrameLayout android:id="#id/search_holder" android:visibility="invisible" android:layout_width="fill_parent" android:layout_height="#dimen/abc_action_bar_default_height_material" />
<ImageView android:layout_gravity="bottom|center|right" android:id="#id/fab" android:background="#drawable/input_circle_green" android:layout_width="#dimen/submit_button_size" android:layout_height="#dimen/submit_button_size" android:layout_margin="16.0dip" android:scaleType="center" />
<ImageView android:layout_gravity="bottom|center|right" android:id="#id/fab_aux" android:background="#drawable/input_circle_grey" android:visibility="gone" android:layout_width="46.0dip" android:layout_height="46.0dip" android:layout_marginRight="21.0dip" android:layout_marginBottom="88.0dip" android:scaleType="center" android:contentDescription="#string/menuitem_new_text_status" />
</FrameLayout>
</LinearLayout>
<FrameLayout android:id="#id/preview_container" android:layout_width="fill_parent" android:layout_height="fill_parent" />
</FrameLayout>
I think the line,
<com.whatsapp.HomePagerSlidingTabStrip android:id="#id/tabs" android:background="#color/primary" android:layout_width="fill_parent" android:layout_height="#dimen/tab_height" whatsapp:pstsIndicatorColor="#color/tab_indicator" whatsapp:pstsDividerColor="#android:color/transparent" whatsapp:pstsIndicatorHeight="3.0dip" whatsapp:pstsUnderlineHeight="1.0dip" whatsapp:pstsTabPaddingLeftRight="8.0dip" whatsapp:pstsShouldExpand="true" />
Is the tab layout you have given in the question.
Also there is another layout file, which contains the custom view for tab title. The tab title in whatsapp ha badges for message counter, missed calls etc
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout android:gravity="center" android:layout_gravity="center" android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="48.0dip" android:animateLayoutChanges="true">
<TextView android:textSize="14.0sp" android:textStyle="bold" android:textColor="#android:color/white" android:ellipsize="end" android:id="#id/tab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:layout_weight="1.0" android:textAllCaps="true" />
<TextView android:textSize="11.0sp" android:textStyle="bold" android:textColor="#color/primary" android:ellipsize="end" android:gravity="center" android:layout_gravity="center_vertical" android:id="#id/badge" android:background="#drawable/tab_badge_background_inactive" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="5.0dip" android:minWidth="16.0dip" android:singleLine="true" />
<ImageView android:id="#id/icon" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
</FrameLayout>
My point is it may not be that easy to get what you are looking for. WhatsApp did that using custom views and custom tablayout.
If anyone knows a simpler solution, that would be great.
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.getChildAt(0).getLayoutParams().width = 20;

How to next child tablelayout android

I have a TableLayout within a ScrollView.
I need to go to the next LinearLayout (dynamically created) which is within the TableView clicking a close button and return to the previous LinearLayout by clicking the back button.
Follow my XML as I am creating the TableView:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:id="#+id/myLayout"
android:layout_height="match_parent"
android:layout_weight="1">
<android.support.v7.widget.Toolbar
android:id="#+id/tb_pergunta"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize" />
<ScrollView
android:id="#+id/sv_table"
android:layout_height="match_parent"
android:scrollbars="horizontal|vertical"
android:layout_width="match_parent"
android:layout_marginTop="5dip"
android:scrollbarStyle="outsideInset"
android:fillViewport="true">
<TableLayout
android:id="#+id/tl_principal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</TableLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="14">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ir para pergunta nÂș:"
android:id="#+id/btnProximaPergunta"
android:visibility="gone" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/botton_back"
android:id="#+id/btnBackGroupExpandable" />
<EditText
android:layout_width="99dp"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:id="#+id/edtProximaPergunta"
android:textAlignment="center" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/botton_next"
android:id="#+id/btnNextGroupExpandable" />
</LinearLayout>
</LinearLayout>
How can I do this?
You can give each LinearLayout a randomly generated ID as described here.
Store those IDs in an array and then you can easily call any of them in any order.

need android layout advise

i want to create layout as attached below.
As you see i have added fixed buttons to bottom on the layout.
and now i have problem when content part has more than 9 elements.
While it is going to scroll, last elements are hiding back of the bottom buttons and not scrolling fully as below:
Please give me advise how to do it? Please notice i am not professional android developer.
I am now going to attach my xml layout files. Here you are:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:elevation="0dp"
android:popupTheme="#style/AppTheme.PopupOverlay"
android:theme="#style/ToolbarColoredBackArrow" />
<android.support.design.widget.TabLayout
android:id="#+id/tab_layout"
style="#style/MyCustomTabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/toolbar"
app:tabGravity="fill" />
</android.support.design.widget.AppBarLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</ScrollView>
<LinearLayout
android:id="#+id/ButtonsLinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#F5F5F5"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="#808080" />
<LinearLayout
android:id="#+id/footer_button_icons_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#F5F5F5"
android:orientation="horizontal">
<android.support.v7.widget.AppCompatButton
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#F5F5F5"
android:drawablePadding="3dp"
android:drawableTop="#drawable/ic_xxx"
android:gravity="center|center"
android:text="#string/footer_xxx"
android:textAllCaps="false"
android:textColor="#color/xxx_gray_darker"
android:textSize="12sp" />
<android.support.v7.widget.AppCompatButton
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="#drawable/borderless_button"
android:drawablePadding="3dp"
android:drawableTop="#drawable/ic_xxx"
android:gravity="center|center"
android:text="#string/footer_xxx"
android:textAllCaps="false"
android:textColor="#FFFFFF"
android:textSize="12sp" />
<android.support.v7.widget.AppCompatButton
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#F5F5F5"
android:drawablePadding="3dp"
android:drawableTop="#drawable/ic_xxx"
android:gravity="center|center"
android:text="#string/footer_xxx"
android:textAllCaps="false"
android:textColor="#color/xxx_gray_darker"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Here is a First Fragment layout xml of ViewPager
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:paddingTop="40dp"
android:showDividers="middle"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<GridView
android:id="#+id/gridView"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:numColumns="3"
android:stretchMode="columnWidth"
android:verticalSpacing="20dp"></GridView>
</LinearLayout>
set android:layout_above in your scrollView
<ScrollView android:layout_above="#id/ButtonsLinearLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
your ScrollView should be above LinearLayout which consist Buttons.
There is no need to use ScrollView in view pager. Remove ScrollView for the ViewPager whose id is pager.
paddingBottom is what you want. Add paddingBottom to your ScrollView or any other layout which is the container of the items. The padding should be slightly greater than the height of the bottom strip.
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="48dp">

Categories

Resources