skip to Main Content

I am trying to attach a TableLayout into my Navigation drawer activity. The TableLayout should not show when I click the menu items. 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"/>
            <TableLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="#CCC"
                android:layout_marginTop="50pt"
                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>
                <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 occupied"/>
                    <TextView
                        android:layout_marginLeft="1dp"
                        android:padding="5dp"
                        android:background="#FFF"
                        android:gravity="right"
                        android:id="@+id/noqrtrocc"
                        android:text="456789"/>
                </TableRow>
                <TableRow
                    android:background="#CCC"
                    android:paddingBottom="1dp"
                    android:paddingRight="1dp">
                    <TextView
                        android:layout_marginLeft="1dp"
                        android:padding="5dp"
                        android:background="#FFF"
                        android:text="Total meter charge calculated till date"/>
                    <TextView
                        android:layout_marginLeft="1dp"
                        android:padding="5dp"
                        android:background="#FFF"
                        android:gravity="right"
                        android:id="@+id/totmetchrg"
                        android:text="456789"/>
                </TableRow>
            </TableLayout>
            <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"/>
</android.support.v4.widget.DrawerLayout>

For some reason, the table is visible even when I click on any menu items, I want it to be visible only in the main page. How do I do that?

2

Answers


  1. "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">
    
    Login or Signup to reply.
  2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search