<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#1E1E1E"
android:orientation="vertical" >
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.5"
android:weightSum="1" >
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" >
<Button
android:id="@+id/button7"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/ld"
android:gravity="center|bottom"
android:paddingBottom="10dp"
android:text="Button 3"
android:textSize="18sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.5"
android:weightSum="1" >
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5" >
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/ld"
android:gravity="center|bottom"
android:paddingBottom="10dp"
android:singleLine="false"
android:textSize="18sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5" >
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/ld"
android:gravity="center|bottom"
android:paddingBottom="10dp"
android:singleLine="false"
android:text="Botton 2"
android:textSize="18sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.5"
android:weightSum="1" >
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5" >
<Button
android:id="@+id/button3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/ld"
android:gravity="center|bottom"
android:paddingBottom="10dp"
android:text="Button 3"
android:textSize="18sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5" >
<Button
android:id="@+id/button4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/ld"
android:gravity="center|bottom"
android:paddingBottom="10dp"
android:text="Button 4"
android:textSize="18sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.5"
android:weightSum="1" >
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5" >
<Button
android:id="@+id/button5"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/ld"
android:gravity="center|bottom"
android:paddingBottom="10dp"
android:text="Button 5"
android:textSize="18sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5" >
<Button
android:id="@+id/button6"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000"
android:gravity="center|bottom"
android:paddingBottom="10dp"
android:text="Button 6"
android:textSize="18sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
</TableRow>
</TableLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_alignParentBottom="true"
android:background="#fff"
android:weightSum="6" >
<Button
android:id="@+id/b1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_below="@id/b1"
android:layout_weight="1"
android:background="#fff"
android:drawableTop="@drawable/home1"
android:text="Home"
android:textSize="8dp" />
<Button
android:id="@+id/b2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/b2"
android:layout_weight="1"
android:background="#fff"
android:drawableTop="@drawable/abt"
android:text="About"
android:textSize="8dp" />
<Button
android:id="@+id/b3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/b3"
android:layout_weight="1"
android:background="#fff"
android:drawableTop="@drawable/ser"
android:text="Services"
android:textSize="8dp" />
<Button
android:id="@+id/b4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/b4"
android:layout_weight="1"
android:background="#fff"
android:drawableTop="@drawable/cnt1"
android:text="Portfolio"
android:textSize="8dp" />
<Button
android:id="@+id/b5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/b5"
android:layout_weight="1"
android:background="#fff"
android:drawableTop="@drawable/spt"
android:text="Support"
android:textSize="8dp" />
<Button
android:id="@+id/b6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/b6"
android:layout_weight="1"
android:background="#fff"
android:drawableTop="@drawable/inbox"
android:text="Marketing"
android:textSize="8dp" />
</LinearLayout>
</RelativeLayout>
I Need to have scroll view in the relative layout with fixed footer. the table layout alone should have scroll view and footer should be fixed
Add a scroll view as a parent of your TableLayout and align it above bottom layout.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#1E1E1E" >
<LinearLayout
android:id="@+id/bottombar"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_alignParentBottom="true"
android:background="#fff"
android:weightSum="6" >
<Button
android:id="@+id/b1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_below="@id/b1"
android:layout_weight="1"
android:background="#fff"
android:drawableTop="@drawable/home1"
android:text="Home"
android:textSize="8dp" />
<Button
android:id="@+id/b2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/b2"
android:layout_weight="1"
android:background="#fff"
android:drawableTop="@drawable/abt"
android:text="About"
android:textSize="8dp" />
<Button
android:id="@+id/b3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/b3"
android:layout_weight="1"
android:background="#fff"
android:drawableTop="@drawable/ser"
android:text="Services"
android:textSize="8dp" />
<Button
android:id="@+id/b4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/b4"
android:layout_weight="1"
android:background="#fff"
android:drawableTop="@drawable/cnt1"
android:text="Portfolio"
android:textSize="8dp" />
<Button
android:id="@+id/b5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/b5"
android:layout_weight="1"
android:background="#fff"
android:drawableTop="@drawable/spt"
android:text="Support"
android:textSize="8dp" />
<Button
android:id="@+id/b6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/b6"
android:layout_weight="1"
android:background="#fff"
android:drawableTop="@drawable/inbox"
android:text="Marketing"
android:textSize="8dp" />
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/bottombar" >
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.5"
android:weightSum="1" >
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" >
<Button
android:id="@+id/button7"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/ld"
android:gravity="center|bottom"
android:paddingBottom="10dp"
android:text="Button 3"
android:textSize="18sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.5"
android:weightSum="1" >
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5" >
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/ld"
android:gravity="center|bottom"
android:paddingBottom="10dp"
android:singleLine="false"
android:textSize="18sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5" >
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/ld"
android:gravity="center|bottom"
android:paddingBottom="10dp"
android:singleLine="false"
android:text="Botton 2"
android:textSize="18sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.5"
android:weightSum="1" >
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5" >
<Button
android:id="@+id/button3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/ld"
android:gravity="center|bottom"
android:paddingBottom="10dp"
android:text="Button 3"
android:textSize="18sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5" >
<Button
android:id="@+id/button4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/ld"
android:gravity="center|bottom"
android:paddingBottom="10dp"
android:text="Button 4"
android:textSize="18sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.5"
android:weightSum="1" >
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5" >
<Button
android:id="@+id/button5"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/ld"
android:gravity="center|bottom"
android:paddingBottom="10dp"
android:text="Button 5"
android:textSize="18sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5" >
<Button
android:id="@+id/button6"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000"
android:gravity="center|bottom"
android:paddingBottom="10dp"
android:text="Button 6"
android:textSize="18sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
</TableRow>
</TableLayout>
</ScrollView>
</RelativeLayout>
Use this as your top level and add to it what you need:
<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:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:weightSum="1"
tools:context=".MainActivityFragment">
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.9">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
</TableLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".1"
android:orientation="horizontal"
android:id="@+id/footer">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
Inside your given xml code add a scroll view and replace your TableLayout inside it. Like this,Let it be first layout.
<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#1E1E1E">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
//contents inside table layout
</TableLayout>
</ScrollView>
</RelativeLayout>
Now create another footer Layout,like this,let it be second layout.
<RelativeLayout>
//things to be appeared on footer are added here
</RelativeLayout>
Inside your java code,get both the layouts using their ids, set the second layout as footter to the first layout.
firstlayout.addFooterView(secondlayout);
Now you can get a fixed footer and scrolling will be only within the first layouts table layout.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.