try to get this(the header with the picture) :
And this is my code :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
tools:context=".MainActivity">
<include layout="#layout/toolbar" />
<android.support.v4.widget.DrawerLayout
android:layout_width="match_parent"
android:id="#+id/drawerLayout"
android:layout_height="match_parent">
<!-- activity view -->
<RelativeLayout
android:layout_width="match_parent"
android:background="#fff"
android:layout_height="match_parent">
<TextView
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:textColor="#000"
android:text="Activity Content"
android:layout_height="wrap_content" />
<com.shamanland.fab.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher"
app:floatingActionButtonColor="#000000"
app:floatingActionButtonSize="mini"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="16dp"
android:layout_marginBottom="20dp"
/>
</RelativeLayout>
<!-- navigation drawer -->
<RelativeLayout
android:layout_gravity="left|start"
android:layout_width="match_parent"
android:background="#fff"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/top_control_bar">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="bababababbababababbababababba"/>
</RelativeLayout>
<ListView
android:id="#+id/left_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#eee"
android:background="#fff"
android:dividerHeight="1dp" />
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
I don't know if i have to create a new layout above the list or something else.
I've seen that there is a listview header in android but this doesn't work in my example.
Thanks for your help
Try the Below code......
<RelativeLayout
android:layout_gravity="left|start"
android:layout_width="match_parent"
android:background="#fff"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/top_control_bar">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="bababababbababababbababababba"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/top_control_bar1">
<ImageView
android:id="#+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/ur_image" />
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="start"
android:text="Your Text"
android:textColor="#FFFFFF"
android:textSize="38px" />
</RelativeLayout>
<ListView
android:id="#+id/left_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/top_control_bar1"
android:divider="#eee"
android:background="#fff"
android:dividerHeight="1dp" />
</RelativeLayout>
You will need to create a simple LinearLayout which contains a List. Here's an example:
<LinearLayout
android:id="#+id/linearDrawer"
android:layout_width="260dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#color/navigation_items"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:id="#+id/userContent"
android:layout_width="260dp"
android:layout_height="150dp"
android:background="#color/black"
android:gravity="center_vertical"
android:paddingRight="10dp">
<RelativeLayout
android:id="#+id/userDrawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/transparent">
<ImageView
android:id="#+id/ImgDrawer"
android:layout_width="260dp"
android:layout_height="200dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:contentDescription="#string/dummy_user_description"
android:scaleType="centerCrop"
android:src="#drawable/ic_user" />
<RelativeLayout
style="#style/textView_title_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true">
<TextView
android:id="#+id/txt_user_name_drawer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/dummy_username"
android:textAllCaps="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white" />
<TextView
android:id="#+id/txt_user_lastname_drawer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/txt_user_name_drawer"
android:text="#string/dummy_user_description"
android:textAllCaps="false"
android:textColor="#color/white"
android:textSize="12sp" />
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
<View
android:id="#+id/viewSeparator"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#color/blue_dark" />
<ListView
android:id="#+id/listDrawer"
android:layout_width="260dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#color/navigation_items"
android:cacheColorHint="#color/transparent"
android:choiceMode="singleChoice"
android:divider="#android:color/transparent"
android:dividerHeight="1dp" />
The Layout itself contains the FrameLayout (Content) and the Drawer.
Sample:
<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"
tools:context="com.androiddevworker.rateit.view.RatingActivity">
<FrameLayout
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<fragment
android:id="#+id/navigation_drawer"
android:layout_width="#dimen/navigation_drawer_width"
android:layout_height="fill_parent"
android:layout_gravity="start"
android:name="com.androiddevworker.rateit.view.fragments.RatingNavigationDrawerFragment"
tools:layout="#layout/navigation_main_include" />
In your activity you can get it by using
private RatingNavigationDrawerFragment mRatingNavigationDrawerFragment;
mRatingNavigationDrawerFragment = (RatingNavigationDrawerFragment) getSupportFragmentManager().findFragmentById(R.id.navigation_drawer);
while the RatingNavigationDrawerfragment (example) is just a simple fragment.
Related
How to add top drawer and bottom tab navigation in whole application?
I tried to combine 2 activity in android studio and its causing design issue. Its not working
For the bottom navigation
https://developer.android.com/reference/android/support/design/widget/BottomNavigationView
For Top drawer exaplain a little what exactly you want
You can achieve this throughout your whole Project in this way.
Use this as an activity_main.xml like as your MainActivity.java class.
<?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_home"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="#dimen/dp_180"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/top_lay"
android:layout_width="match_parent"
android:layout_height="#dimen/nav_header_height"
android:background="#color/colorPrimary"
android:orientation="vertical"
android:theme="#style/ThemeOverlay.AppCompat.Dark">
<RelativeLayout
android:id="#+id/userimageLay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<com.team.helperclasses.CircleImageView
android:id="#+id/userimage"
android:layout_width="#dimen/dp_100"
android:layout_height="#dimen/dp_100"
android:src="#mipmap/side_menu_profile_"
app:civ_border_color="#color/colorPrimary"
app:civ_border_overlay="true"
app:civ_border_width="1dp" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/editProfile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/top_lay"
android:paddingBottom="#dimen/dp_5"
android:paddingTop="#dimen/dp_5">
<TextView
android:id="#+id/editProfileText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/editProfileImage"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/dp_8"
android:text="#string/editProfile"
android:textColor="#color/dull_black"
android:textSize="#dimen/sp_18" />
<ImageView
android:id="#+id/editProfileImage"
android:layout_width="#dimen/dp_45"
android:layout_height="#dimen/dp_45"
android:layout_centerHorizontal="true"
android:src="#mipmap/side_menu_profile" />
</RelativeLayout>
<View
android:id="#+id/editProfiledivider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/editProfile"
android:background="#color/light_black" />
<RelativeLayout
android:id="#+id/sharedWall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/editProfile"
android:paddingBottom="#dimen/dp_5"
android:paddingTop="#dimen/dp_5">
<TextView
android:id="#+id/sharedWallText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/shareWallImage"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/dp_8"
android:text="#string/sharedWall"
android:textColor="#color/dull_black"
android:textSize="#dimen/sp_18" />
<ImageView
android:id="#+id/shareWallImage"
android:layout_width="#dimen/dp_45"
android:layout_height="#dimen/dp_45"
android:layout_centerHorizontal="true"
android:src="#mipmap/wall" />
</RelativeLayout>
<View
android:id="#+id/shareWallDivider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/sharedWall"
android:background="#color/light_black" />
<RelativeLayout
android:id="#+id/changeLang"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/shareWallDivider"
android:paddingBottom="#dimen/dp_5"
android:paddingTop="#dimen/dp_5">
<TextView
android:id="#+id/changeLangText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/changeLangImage"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/dp_8"
android:text="#string/changeLanguage"
android:textColor="#color/dull_black"
android:textSize="#dimen/sp_18" />
<ImageView
android:id="#+id/changeLangImage"
android:layout_width="#dimen/dp_45"
android:layout_height="#dimen/dp_45"
android:layout_centerHorizontal="true"
android:src="#mipmap/language" />
</RelativeLayout>
<View
android:id="#+id/changeLangdivider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/changeLang"
android:background="#color/light_black" />
<RelativeLayout
android:id="#+id/logout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/changeLangdivider"
android:paddingBottom="#dimen/dp_5"
android:paddingTop="#dimen/dp_5">
<TextView
android:id="#+id/logoutText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/logoutImage"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/dp_8"
android:text="#string/logout"
android:textColor="#color/dull_black"
android:textSize="#dimen/sp_18" />
<ImageView
android:id="#+id/logoutImage"
android:layout_width="#dimen/dp_45"
android:layout_height="#dimen/dp_45"
android:layout_centerHorizontal="true"
android:src="#mipmap/log_out" />
</RelativeLayout>
</RelativeLayout>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
& the Layout app_bar_home.xml looks like this.
<?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.team.activities.Home">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layoutDirection="ltr"
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:title="#string/app_name"
app:popupTheme="#style/AppTheme.PopupOverlay"
app:theme="#style/ToolBarStyle">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/search"
android:gravity="left"
android:text="#string/app_name"
android:textColor="#color/black"
android:textSize="#dimen/sp_22" />
<ImageView
android:id="#+id/searchHome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/notificationLay"
android:src="#mipmap/search" />
<RelativeLayout
android:id="#+id/notificationLay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="#dimen/dp_5">
<ImageView
android:id="#+id/notification"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="#dimen/dp_5"
android:src="#mipmap/notification" />
<ImageView
android:id="#+id/notify"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/notification"
android:padding="#dimen/dp_5"
android:src="#drawable/counter_bg" />
</RelativeLayout>
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<include layout="#layout/content_home" />
</android.support.design.widget.CoordinatorLayout>
& content_home.xml in which you can define the things as per your requirement in the application.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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/content_home"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.team.activities.Home"
tools:showIn="#layout/app_bar_home">
<RelativeLayout
android:id="#+id/fragment_space"
android:name="com.presence.fragments.HomeFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/bottom_lay" />
<LinearLayout
android:id="#+id/bottom_lay"
android:layout_width="match_parent"
android:layout_height="#dimen/dp_50"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:background="#color/colorPrimary"
android:layoutDirection="ltr"
android:orientation="horizontal">
<RelativeLayout
android:id="#+id/tab_create"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:id="#+id/image_create"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/text_create"
android:layout_centerHorizontal="true"
android:src="#mipmap/create" />
<TextView
android:id="#+id/text_create"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="#string/create"
android:textColor="#color/white"
android:textSize="#dimen/sp_10" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/tab_received"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:id="#+id/image_received"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/text_received"
android:layout_centerHorizontal="true"
android:src="#mipmap/recived" />
<TextView
android:id="#+id/text_received"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="#string/received"
android:textColor="#color/white"
android:textSize="#dimen/sp_10" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/tab_sent"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:id="#+id/image_sent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/text_sent"
android:layout_centerHorizontal="true"
android:src="#mipmap/sent" />
<TextView
android:id="#+id/text_sent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="#string/sent"
android:textColor="#color/white"
android:textSize="#dimen/sp_10" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/tab_website"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:id="#+id/image_website"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/text_travel"
android:layout_centerHorizontal="true"
android:src="#mipmap/web" />
<TextView
android:id="#+id/text_travel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="#string/booking"
android:textColor="#color/white"
android:textSize="#dimen/sp_10" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
Try this hope it helps you.
I have the problem that my Toolbar overlaid my ListView.
short info: I've implemented a Navigation Drawer.
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/project_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
tools:ignore="MergeRootFrame">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<android.support.v7.widget.Toolbar
android:id="#+id/listview_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:theme="#style/ThemeOverlay.AppCompat.ActionBar" />
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/swipe_to_refresh"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ListView
android:id="#+id/list"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:smoothScrollbar="true" />
</android.support.v4.widget.SwipeRefreshLayout>
<RelativeLayout
android:id="#+id/emptyProjects"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical">
<TextView
android:id="#+id/listviewNoContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Sie haben zur Zeit keine Aufgaben"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#a4a5ae" />
<Button
android:id="#+id/examplesbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:background="#color/kevox"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text="Beispiele anfordern"
android:textColor="#android:color/white" />
</RelativeLayout>
</RelativeLayout>
</FrameLayout>
<ListView
android:id="#+id/navList"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#android:color/background_light"
android:choiceMode="singleChoice"
android:divider="#android:color/darker_gray"
android:dividerHeight="0dp" />
Can someone tell my what I do wrong?
Maybe it's the position in the XML?
Or do I choosed the wrong style?
I followed this Guide:
http://developer.android.com/training/appbar/setting-up.html
Add this line android:layout_below="#+id/container" I have add this .. check this
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/project_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
tools:ignore="MergeRootFrame">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<android.support.v7.widget.Toolbar
android:id="#+id/listview_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:theme="#style/ThemeOverlay.AppCompat.ActionBar" />
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/swipe_to_refresh"
android:layout_width="wrap_content"
android:layout_below="#+id/listview_toolbar"
android:layout_height="wrap_content">
<ListView
android:id="#+id/list"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:smoothScrollbar="true" />
</android.support.v4.widget.SwipeRefreshLayout>
<RelativeLayout
android:id="#+id/emptyProjects"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical">
<TextView
android:id="#+id/listviewNoContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Sie haben zur Zeit keine Aufgaben"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#a4a5ae" />
<Button
android:id="#+id/examplesbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:background="#color/boxcolor"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text="Beispiele anfordern"
android:textColor="#android:color/white" />
</RelativeLayout>
</RelativeLayout>
</FrameLayout>
<ListView
android:id="#+id/navList"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#android:color/background_light"
android:choiceMode="singleChoice"
android:divider="#android:color/darker_gray"
android:dividerHeight="0dp" />
</android.support.v4.widget.DrawerLayout>
i have added footer in tab activity footer is shown in all tabs but problem is that it comes over the data so data at bottom is not visible.
here is my code of xml
<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"
>
<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"
android:id="#+id/relativ_layout"
tools:context=".MainActivity" >
<TabHost
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TabWidget
android:id="#android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ff8800"
android:orientation="horizontal" >
</TabWidget>
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0" >
</FrameLayout>
<android.support.v4.view.ViewPager
android:id="#+id/viewpager"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom" >
</android.support.v4.view.ViewPager>
</LinearLayout>
</TabHost>
// footer *************************************************
<RelativeLayout
android:id="#+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#F00000"
android:gravity="bottom" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Fixed Footer"
android:textColor="#000"
android:textSize="20sp" />
</RelativeLayout>
//********************************************
</RelativeLayout>
<FrameLayout
android:id="#+id/Frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>
<LinearLayout
android:id="#+id/navigation_drawer"
android:layout_width="#dimen/navigation_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
android:orientation="vertical"
android:background="#android:color/white">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="150dp"
android:clickable="true"
android:focusable="true"
android:background="#drawable/navigationdrawer"
>
<TextView
android:id="#+id/txtemail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Shivam1692#gmail.com"
android:layout_alignParentBottom="true"
android:layout_marginLeft="10dp"
android:layout_marginBottom="10dp"/>
</RelativeLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="15dp"
android:paddingTop="20dp"
android:textColor="#android:color/darker_gray"
android:textStyle="bold"
android:paddingLeft="10dp"
android:paddingRight="16dp"
android:text="TITLE" />
<ListView
android:id="#+id/list_slider"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:listSelector="#drawable/list_selector"
android:divider="#color/list_divider"
android:choiceMode="singleChoice"
android:dividerHeight="0.3dp"
/>
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
please tell me how to add footer below the data.
You can do this by using nested relative layouts, like below
<!-- Header -->
<RelativeLayout
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:gravity="center" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Header"
android:id="#+id/textView" />
</RelativeLayout>
<!-- Footer -->
<RelativeLayout
android:id="#+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Footer"
android:id="#+id/textView2" />
</RelativeLayout>
<!-- Content -->
<!-- Place your content in this layout-->
<RelativeLayout
android:id="#+id/content"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="#id/footer"
android:layout_below="#id/header"
android:gravity="center" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Content"
android:id="#+id/textView4" />
</RelativeLayout>
Result: (Borders added for clarity)
enter code hereJust add a padding bottom 30dp[android:paddingbottom="30dp"] to the LinearLayout which you have used
Or
Change the LinearLayout to RelativeLayout and add android:layout_below="#id/footer"
<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"
>
<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"
android:id="#+id/relativ_layout"
tools:context=".MainActivity" >
<TabHost
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="30dp" >
i working navigation drawer.i successfully created my navigation drawer and program working.
now i want to add Edittext in activity_main.xml file to above ListView.this is a my activity_main.xml code
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ff0000"
android:orientation="vertical" >
<android.support.v4.widget.DrawerLayout
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>
<EditText
android:id="#+id/card_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dip"
android:gravity="center"
android:hint="Enter text"
android:padding="10dip"
android:singleLine="true"
android:textSize="15dp" />
<ListView
android:id="#+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#191919"
android:choiceMode="singleChoice"
android:divider="#android:color/transparent"
android:dividerHeight="0dp" />
</android.support.v4.widget.DrawerLayout>
how i can add edittext to be above listview?
Here is your updated code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ff0000"
android:orientation="vertical" >
<android.support.v4.widget.DrawerLayout
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>
<LinearLayout
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:orientation="vertical" >
<EditText
android:id="#+id/editField"
android:layout_width="match_parent"
android:layout_height="40dp" />
<ListView
android:id="#+id/left_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#191919"
android:choiceMode="singleChoice"
android:divider="#android:color/transparent"
android:dividerHeight="0dp" />
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
You can add your editText on Header ListView
I don't thinks that's a very good idea. If that text field is common for all fragments, then you should consider placing it in ActionBar.
Use Linearlayout to add edittext above listview
<LinearLayout
android:id="#+id/drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#android:color/darker_gray"
android:layout_gravity="start" >
<EditText
android:id="#+id/searchView"
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center"
android:textSize="20sp"
android:hint="Search"
android:imeOptions="actionSearch"
android:imeActionLabel="Search"
android:drawableRight="#drawable/ic_action_search" >
</EditText>
<ListView
android:id="#+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice" />
</LinearLayout>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com /apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/drawer"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:orientation="vertical">
<!-- As the main content view, the view below consumes the entire
space available using match_parent in both dimensions. -->
<FrameLayout
android:id="#+id/content_menu"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="100">
<!-- As the main content view, the view below consumes the entire
space available using match_parent in both dimensions. -->
<FrameLayout
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<EditText
android:id="#+id/card_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dip"
android:gravity="left"
android:hint="Enter text"
android:padding="10dip"
android:singleLine="true"
android:textSize="15dp"
/>
</RelativeLayout>
<include layout="#layout/adapter_drawer" />
</android.support.v4.widget.DrawerLayout>
Your adapter_drawer.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/left_drawer"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#color/red"
>
<EditText
android:id="#+id/card_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dip"
android:gravity="left"
android:hint="Enter text"
android:padding="10dip"
android:singleLine="true"
android:textSize="15dp"
/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<RelativeLayout
android:id="#+id/row_1"
android:layout_width="wrap_content"
android:layout_height="100dip"
android:gravity="center"
android:layout_centerHorizontal="true"
android:layout_weight="20">
<ImageView
android:id="#+id/picture_1"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="#dimen/space_2_x"
android:clickable="true"
android:contentDescription="#string/app_name"
android:padding="#dimen/space_2_x"
android:scaleType="centerCrop"
android:src="#drawable/ic_launcher"
/>
<TextView
android:id="#+id/text_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/picture_1"
android:layout_centerHorizontal="true"
android:clickable="true"
android:gravity="center"
android:text="Home"
android:textColor="#color/white"
android:textSize="#dimen/text_size_small"
/>
</RelativeLayout>
</RelativeLayout>
I Want to show textview but the textview show in behind map fragment
my layout like this :
i want the layout like this :
this is the xml code
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/tv_distance_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="#string/hello_world" />
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/tv_distance_time" />
<FrameLayout
android:id="#+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>
<ListView
android:id="#+id/list_slidermenu"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="#color/list_divider"
android:dividerHeight="1dp"
android:listSelector="#drawable/list_selector"
android:background="#color/list_background"/>
i want to show the textview but the text view cant show cause textview in behind map fragment
Here is the updated UI
<?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.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/tv_distance_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="#string/hello_world" />
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/tv_distance_time" />
<ListView
android:id="#+id/list_slidermenu"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#color/list_background"
android:choiceMode="singleChoice"
android:divider="#color/list_divider"
android:dividerHeight="1dp"
android:listSelector="#drawable/list_selector" />
</android.support.v4.widget.DrawerLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="#000000"
android:gravity="center_vertical" >
<TextView
android:id="#+id/tv_car_modelcharge"
style="#style/textTrackName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/margin_5dp"
android:text="Bandung to jakarta"
android:textColor="#fff" />
<View
android:layout_width="2dp"
android:layout_height="25dp"
android:layout_marginLeft="10dp"
android:background="#fff" />
<TextView
android:id="#+id/tv_car_modelcharge"
style="#style/textTrackName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/margin_5dp"
android:text="Distance: 150km"
android:textColor="#fff" />
<View
android:layout_width="2dp"
android:layout_height="25dp"
android:layout_marginLeft="10dp"
android:background="#fff" />
<TextView
android:id="#+id/tv_car_modelcharge"
style="#style/textTrackName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/margin_5dp"
android:text="Time : 3h"
android:textColor="#fff" />
</LinearLayout>
</RelativeLayout>