How to fix No resource identifier found for attribute '---' in android - android

In my app i want to use navigation drawer with swipe tab layout and i am following this tutorial.But i am getting an exception from xml file called error: No resource identifier found for attribute
'itemTextColor' in package
'com.example.samplenavigationdrawer' How to clear it can any one tell me how to deal with it
this is my XML:
<LinearLayout
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:fitsSystemWindows="true"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/orange"
android:id="#+id/toolbar"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:title="Drawer With Swipe Tabs" />
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="#+id/drawerLayout"
>
<FrameLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/containerView">
</FrameLayout>
<android.support.design.widget.NavigationView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:id="#+id/stuff"
app:itemTextColor="#000000"
app:menu="#menu/drawer_items"
android:layout_marginTop="-24dp"
/>
</android.support.v4.widget.DrawerLayout>
</LinearLayout>

Related

Tablayout is ruined after changing compile sdk version from 23 to 24

I already had an app with a perfectly working tablayout.But after changing the compile sdk version from 23 to 24 a small gap appears in the second tab.
It should look like this.
But it looks like this,with the black gap.
Can anyone tell me how to fix this
Both these tabs use the same layout.
<?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:id="#+id/drawer_layout"
android:layout_width="match_parent" android:layout_height="match_parent"
android:fitsSystemWindows="true" tools:openDrawer="start">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent" android:fitsSystemWindows="true"
tools:context=".MainActivity">
<android.support.design.widget.AppBarLayout android:layout_height="wrap_content"
android:layout_width="match_parent" android:theme="#style/AppTheme.AppBarOverlay">
</android.support.design.widget.AppBarLayout>
<include layout="#layout/dashboard" />
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView android:id="#+id/nav_view"
android:layout_width="wrap_content" android:layout_height="match_parent"
android:layout_gravity="start" android:fitsSystemWindows="true"
app:itemTextColor="#color/drawer_text_color"
app:headerLayout="#layout/nav_header_main" app:menu="#menu/activity_main_drawer" />
dashboard.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="10dp">
<ProgressBar
android:id="#+id/progbar"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/txt"
android:text="These are your active court Proceedings"
android:paddingBottom="10dp"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#D9DCDE"
android:scrollbars="vertical">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
</FrameLayout>
I hope my question is clear.Please give me a solution for this.
Thanks.
From the Documentation
android:fitsSystemWindows
Boolean internal attribute to adjust view layout based on system
windows such as the status bar. If true, adjusts the padding of this
view to leave space for the system windows. Will only take effect if
this view is in a non-embedded activity.
so set *android:fitsSystemWindows = "false" for DrawerLayout and CoordinatorLayout
<?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:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="false"
tools:openDrawer="start">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="false"
tools:context=".MainActivity">
</android.support.design.widget.CoordinatorLayout>
</android.support.v4.widget.DrawerLayout>

Android RelativeLayout Z Order Layering

I have an issue with my activity_main.xml in which the bottombar as shown in my layout below appears to cut off the bottom of my main fragment container and is layered on top of it instead of appearing below it.
The bottombar should appear below the main conatiner instead of layering above it.
Can someone please help me as I have tried everything.
<?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:id="#+id/drawer_layout_new"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="#+id/my_toolbar"
layout="#layout/toolbar">
</include>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="#+id/fragmentContainerNew"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_above="#+id/bottomBar" />
<com.roughike.bottombar.BottomBar
android:id="#+id/bottomBarNew"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
app:bb_tabXmlResource="#xml/bottombar_tabs" />
</RelativeLayout>
</LinearLayout>
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="#menu/activity_main_drawer" />
bottom part of activity_main
You forgot to add proper id #+id/bottomBarNew, Change your value:
<FrameLayout
android:id="#+id/fragmentContainerNew"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_above="#+id/bottomBarNew" /> //<---here

Navigation Drawer Fragment cut off at top

I'm using the Navigation Drawer Template on android and I'm also using fragments. Whenever there is a fragment, the action cuts off the fragment's top. I haven't changed the default code other than adding in the fragment. How do you get the fragment to load below the action bar?
picture of the problem:
*update
Now it looks like this
activity_main.xml
<?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:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="#layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="#menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
fragment xml
<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"
tools:context="com.example.android.slidemenu.TestFragment"
android:orientation="horizontal">
<!-- TODO: Update blank fragment layout -->
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:src="#android:drawable/ic_menu_compass"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TESTTEST"
android:textSize="50sp"/>
</LinearLayout>
app bar main 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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.example.android.slidemenu.MainActivity">
<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:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="#+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.design.widget.CoordinatorLayout>
The FrameLayout needs to be below the Toolbar, and inside the CoordinatorLayout. Try to restructure like so.
Include the "main contents" in the DrawerLayout. Then add the FrameLayout after the AppBarLayout (or include other views if Fragments aren't needed).
The secret line that "pushes" down the FrameLayout is this line
app:layout_behavior="#string/appbar_scrolling_view_behavior"
drawer layout XML
<?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:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="#layout/nav_content"/>
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="#menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
nav_content.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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.example.android.slidemenu.MainActivity">
<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:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="#+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
Put the FrameLayout inside the CoordinatorLayout, after the AppBarLayout.
EDIT: Try removing the android:fitsSystemWindows=true.
Setting android:fitsSystemWindows to false instead of removing it did the trick for me. Thx amitairos for the hint ;).

Visible part of Navigation View when collapsed?

How to set visible part of Navigation View when collapsed and the items are also clickable, but when the user drags the drawer full appears. Im trying to use layout_margionRight but it doesnt work. I want to create Navigation View is like aNavigationSlidingPanel`. Help please. Here is my code:
<?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:fab="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.CoordinatorLayout
android:layout_height="match_parent"
android:layout_width="match_parent">
<FrameLayout
android:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/toolbar_actionbar"
android:layout_width="match_parent"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:layout_height="55dp"
android:background="#drawable/bg_color_toolbar" >
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="#+id/navigation"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="end"
android:background="#drawable/bg_color2"
app:itemTextColor="#color/colorWhite"
app:itemIconTint="#color/colorWhite"
app:menu="#menu/menu_navigation"
app:headerLayout="#layout/nd_head"
android:layout_marginRight="64dp"
android:layout_marginEnd="64dp"
/>
</android.support.v4.widget.DrawerLayout>

Relative layout always seems to work for only drawer layout or frame layout, both child doesn't work together

I have a relative layout in which i have two child .one is drawer layout and the other is a frame layout in which i have used a fragment .The problem is when i keep drawer layout in the top and the frame layout in the bottom,drawer layout doesn't work and if do the opposite,frame layout doesn't
this is my relative layout
<RelativeLayout 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">
<include
android:id="#+id/toolbar_actionbar"
layout="#layout/mtoolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/toolbar_actionbar">
<fragment
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:name="com.example.rohit.newmastervocab.FloatingFragment"
android:id="#+id/fragment2"
android:layout_alignParentStart="true"
tools:layout="#layout/fragmentfloating"
android:layout_alignTop="#+id/drawer"
android:layout_gravity="center_horizontal|bottom" />
</FrameLayout>
<android.support.v4.widget.DrawerLayout android:id="#+id/drawer1"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:layout_below="#+id/toolbar_actionbar"
android:layout_alignParentBottom="true">
<ListView
android:id="#+id/drawerlist1"
android:layout_width="240dp"
android:layout_height="match_parent"
android:entries="#array/navigation_items"
android:background="#F3F6C8"
android:layout_gravity="start">
</ListView>
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
Mike M. is absolutely right: you need to keep FrameLayout as one of the Children of DrawerLayout.
I've updated your XML a bit, take a look:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar_actionbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
<FrameLayout
android:layout_below="#+id/toolbar_actionbar"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:layout_gravity="center_horizontal|bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:name="com.example.rohit.newmastervocab.FloatingFragment"
android:id="#+id/fragment2"/>
</FrameLayout>
</RelativeLayout>
<ListView
android:id="#+id/drawerlist1"
android:layout_width="240dp"
android:layout_height="match_parent"
android:entries="#array/navigation_items"
android:background="#F3F6C8"
android:fitsSystemWindows="true"
android:layout_gravity="start"/>
</android.support.v4.widget.DrawerLayout>
Now drawer works just as expected and Fragment is stick to the bottom|center of the screen.

Categories

Resources