AEMLoviji
AEMLoviji

Reputation: 3257

need android layout advise

i want to create layout as attached below.

enter image description here

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:

enter image description here

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>

Upvotes: 0

Views: 76

Answers (3)

user5493659
user5493659

Reputation:

There is no need to use ScrollView in view pager. Remove ScrollView for the ViewPager whose id is pager.

Upvotes: 2

Mangesh
Mangesh

Reputation: 5841

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">

Upvotes: 0

Ravi
Ravi

Reputation: 35549

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.

Upvotes: 2

Related Questions