Home > Software design >  TableLayout fixed to the top inside NavigationView
TableLayout fixed to the top inside NavigationView

Time:02-24

I am trying to attach a TableLayout into my Navigation drawer activity. This is my XML file:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
    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:id="@ id/drawer_layout"
    android:fitsSystemWindows="true"
    tools:context=".Homepage"
    tools:openDrawer="start">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <android.support.v7.widget.Toolbar
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="@color/colorPrimary"
                android:id="@ id/toolbar"
                android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                android:elevation="4dp"/>

            <FrameLayout
                android:id="@ id/fragment_container"
                android:layout_width="match_parent"
                android:layout_height="match_parent"/>

        </LinearLayout>
    <android.support.design.widget.NavigationView
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:id="@ id/nav_view"
        app:headerLayout="@layout/nav_header"
        app:menu="@menu/drawer_menu"/>
    <TableLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#CCC"
        android:layout_marginTop="50pt" <!--not working-->
        android:paddingTop="1dp"
        android:stretchColumns="0"
        android:id="@ id/tlTable01">

        <TableRow
            android:background="#CCC"
            android:paddingBottom="1dp"
            android:paddingRight="1dp">
            <TextView
                android:layout_marginLeft="1dp"
                android:padding="5dp"
                android:background="#FFF"
                android:text="Total quarters registered"/>
            <TextView
                android:layout_marginLeft="1dp"
                android:padding="5dp"
                android:background="#FFF"
                android:gravity="right"
                android:id="@ id/noqrtrreg"
                android:text="123456"/>
        </TableRow>
        ......
    </TableLayout>
</android.support.v4.widget.DrawerLayout>

For some reason, the table is fixed to the top of the screen i.e., it blocks the navigation bar, I want to move it a little lower. How do I move the table's position?

CodePudding user response:

"pt" is not recognized by android.

<TableLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="#CCC"
    android:layout_marginTop="50dp" <!--dp instead of pt-->
    android:paddingTop="1dp"
    android:stretchColumns="0"
    android:id="@ id/tlTable01">

CodePudding user response:

edit: looks like op wrongly implemented DrawerLayout, I'm suggesting to read again doc a do it as it should be

pt isn't a proper unit in here, quoting from DOC 1pt is

1/72 of an inch based on the physical size of the screen

just use dp like in other attributes

android:layout_marginTop="50dp"

check out all available units and differences between them in HERE

  • Related