ListView overlaid by Toolbar in Android - android

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>

Related

The Whole DrawerLayout is scrollable

I am trying to read the layout code but couldn't get why.
I have a code for drawerlayout and the problem is the whole drawerLayout is scroll able i just want to the items list view scroll able not the header and i couldn't figure it out because it looks like all components are custom made.
Can any one have a look at it..
Thanks in advance
<?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:context="com.activities.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
style="#style/ToolBarStyle"
android:layout_width="match_parent"
android:layout_height="#dimen/abc_action_bar_default_height_material"
android:background="?attr/colorPrimary">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="#dimen/abc_action_bar_default_height_material">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:adjustViewBounds="true"
android:scaleType="centerInside"
android:src="#drawable/menu_logo" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
<ViewFlipper
android:id="#+id/loading_switcher"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/checkout_container">
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:elevation="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:orientation="vertical"
android:padding="10dp"
app:layout_scrollFlags="scroll|enterAlways">
<com.views.font.CustomFontTextView
android:id="#+id/location_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/ic_location_on_black_18dp"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:singleLine="true"
android:text="Pick Location"
android:textColor="#color/colorPrimary"
android:textSize="15sp" />
<com.views.font.CustomFontTextView
android:id="#+id/locality_info_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:singleLine="true"
android:textColor="#android:color/black"
android:textSize="12sp" />
</LinearLayout>
</android.support.design.widget.AppBarLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" app:layout_behavior="#string/appbar_scrolling_view_behavior">
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/product_list_swipe_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp">
<android.support.v7.widget.RecyclerView
android:id="#+id/products_list_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
<com.views.CheckoutShelfView
android:id="#+id/checkout_container"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_alignParentBottom="true" />
</RelativeLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical">
<com.views.font.CustomFontTextView
android:id="#+id/error_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:gravity="center"
android:textColor="#color/grey_bg"
android:textSize="20sp" />
<com.views.font.CustomFontTextView
android:id="#+id/error_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:background="#drawable/shape_green_fill_round_5dp"
android:drawablePadding="2dp"
android:gravity="center_vertical"
android:paddingBottom="5dp"
android:paddingLeft="4dp"
android:paddingRight="8dp"
android:paddingTop="5dp"
android:textAllCaps="false"
android:textColor="#android:color/white" />
</LinearLayout>
</ViewFlipper>
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.NavigationView
android:id="#+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="#layout/header_navigation"
app:itemIconTint="#color/colorPrimary"
app:itemTextColor="#color/colorPrimary"
app:menu="#menu/navigation_menu">
<com.views.font.CustomFontTextView
android:id="#+id/version_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:background="#android:color/white"
android:gravity="center"
android:padding="3dp"
android:textSize="10sp">
</com.views.font.CustomFontTextView>
</android.support.design.widget.NavigationView>
</ScrollView>
</android.support.v4.widget.DrawerLayout>
try this:
Remove Scrollview from the layout:
try this:
<android.support.design.widget.NavigationView
android:id="#+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/header_navigation"
app:itemIconTint="#color/colorPrimary"
app:itemTextColor="#color/colorPrimary"
app:menu="#menu/navigation_menu" />
In activity;
//mNavigationView is your navigation view
mNavViewHeaderLayout = LayoutInflater.from(MainActivity.this).inflate(R.layout.header_navigation, mNavigationView);
//to access content in header view
mTextview = (TextView)mNavViewHeaderLayout.findViewById(R.id.textview);

actionBar is goned when input edittext

My issue is the editText on the tabLayout is child fragment , when i input edittext the actionbar will up and disappear.
I try to add the android:windowSoftInputMode="adjustPan" or add ScrollView on the fragment xml, they are no working.
I can't find the same issue on internet.
Is anyone can teach me the solution,please.
Parent page:
<?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"
android:id="#+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF">
<!--my actionbar is overhere-->
<android.support.v7.widget.Toolbar
android:id="#+id/id_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:theme="#style/ToolBarStyle"
app:layout_scrollFlags="scroll|enterAlways"
android:background="#FF6699">
<TextView
android:id="#+id/textTitle"
android:textSize="18dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#android:color/background_light" />
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<!--Parent Fragment change from here-->
<FrameLayout
android:id="#+id/mainFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="270dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#android:color/white"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header"
app:menu="#menu/drawer_menu"
app:itemIconTint="#color/colorPrimary"/>
</android.support.v4.widget.DrawerLayout>
Child page:
<LinearLayout 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:background="#android:color/darker_gray"
android:orientation="vertical"
tools:context=".SubpagesLayout.Homepage">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="8dp"
android:background="#android:color/white"></LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/background_light"
android:orientation="horizontal">
<ImageView
android:layout_width="80dp"
android:layout_height="80sp"
android:id="#+id/genderIcon"
android:layout_gravity="center"
android:layout_weight="1"
app:srcCompat="#drawable/photo_default_female" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/background_light">
<TextView
android:text="Name"
android:textColor="#android:color/black"
android:textSize="30dp"
android:textStyle="bold"
android:gravity="center"
android:layout_marginLeft="125dp"
android:id="#+id/textNameAges"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:text="543"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:background="#android:color/background_light"
android:layout_width="match_parent"
android:layout_height="10dp"></LinearLayout>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white">
<!--Child fragment change by the TabLayouts-->
<!--body_weight_fragment is one of the tabs-->
<android.support.design.widget.TabLayout
android:id="#+id/tabLayoutHomePage"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_weight="1"
android:background="#color/colorPrimary"
app:tabTextColor="#android:color/white">
</android.support.design.widget.TabLayout>
<view
android:id="#+id/viewPager"
class="android.support.v4.view.ViewPager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
</android.support.design.widget.AppBarLayout>
</LinearLayout>
body_weight_fragment:
<LinearLayout 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:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="10dp">
<!--input editText will let actionbar disappear-->
<EditText
android:id="#+id/editHeight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:gravity="center"
android:hint="cm"
android:inputType="number"
android:windowSoftInputMode="adjustPan" />
<Button
android:id="#+id/btnCaculate"
android:layout_width="2dp"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:background="#drawable/corner_pink"
android:text="caculate"
android:textColor="#android:color/white" />
<EditText
android:id="#+id/editWeight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:gravity="center"
android:hint="kg"
android:inputType="number" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:hint="show result"
android:paddingTop="8dp" />
</LinearLayout>
<com.github.mikephil.charting.charts.PieChart
android:id="#+id/chart"
android:layout_width="match_parent"
android:layout_height="match_parent"></com.github.mikephil.charting.charts.PieChart>
</LinearLayout>
try it in manifest: add (adjustResize + adjustPan) for parent activity
<activity
android:name="main"
android:windowSoftInputMode="adjustPan|adjustResize"/>
I found a solution by myself,i have to use scrollView include the toolaBar.Just like above
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="#+id/id_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:theme="#style/ToolBarStyle"
app:layout_scrollFlags="scroll|enterAlways"
android:background="#FF6699">
<TextView
android:id="#+id/textTitle"
android:textSize="18dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#android:color/background_light" />
</android.support.v7.widget.Toolbar>
</ScrollView>

How to manage grid-view with slider and banner

In my activity i need banner, grid-view and slider but the grid-view is not fit to screen after installing app into mobile please help me. here is my xml file.and also set scrollview to all contents in xml.I need output like this screenBut my screen display like this
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:custom="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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="#+id/container_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar" />
</LinearLayout>
<ViewFlipper
android:id="#+id/flipper1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:flipInterval="3000"
android:inAnimation="#android:anim/slide_in_left"
android:outAnimation="#android:anim/slide_out_right">
<ImageView
android:layout_width="match_parent"
android:layout_height="110dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="-9dp"
android:contentDescription="ImageOne"
android:src="#drawable/banners" />
<!-- <ImageView
android:src="#drawable/handmadeproducts"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="ImageTwo"
android:layout_gravity="center_horizontal"
/>-->
</ViewFlipper>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<GridView
android:id="#+id/grid"
android:layout_width="fill_parent"
android:layout_height="270dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_margin="30dp"
android:layout_marginTop="-10dp"
android:columnWidth="200dp"
android:gravity="center"
android:horizontalSpacing="25dp"
android:numColumns="3"
android:verticalSpacing="20dp" />
<android.support.v7.widget.RecyclerView
android:id="#+id/my_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:scrollbars="none" />
</LinearLayout>
</ScrollView>
</LinearLayout>
<FrameLayout
android:id="#+id/container_body"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<fragment
android:id="#+id/fragment_navigation_drawer"
android:name="com.dk.buyolx.activity.FragmentDrawer"
android:layout_width="#dimen/nav_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
app:layout="#layout/fragment_navigation_drawer"
tools:layout="#layout/fragment_navigation_drawer" />
</android.support.v4.widget.DrawerLayout>

Navigation drawer with user header in android

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.

Android navigation drawer in releative layout

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>

Categories

Resources