1

I'm going on with my menu slider bar action and for that I had Googled and finished my slide bar action with help of the below link

http://www.androidhive.info/2013/11/android-sliding-menu-using-navigation-drawer/

Now what i need is to add a profile image and user name with his location (eg:image,john,Chennai) in top of the list. I tried that by creating seperate relative layout for the above three and another separate layout for the rest of list items but i am getting some alignment issues.

enter image description here

here is my layout:

 <?xml version="1.0" encoding="utf-8"?>
<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"

     >
     <RelativeLayout
          android:id="@+id/userimage_top"
           android:layout_width="match_parent"
    android:layout_height="90dp">
        <ImageView
            android:id="@+id/usermenu_image"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_alignParentTop="true"

            androidaddingLeft="5dp"
            androidrc="@drawable/profile_circle" />
    <TextView
        android:id="@+id/user_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/usermenu_image"
        android:layout_below="@+id/usermenu_image"
        android:text="name"
        android:textColor="@color/lightred"
        android:textSize="18dp"
        android:textStyle="bold" />



   <TextView
       android:id="@+id/user_location"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_alignRight="@+id/usermenu_image"
       android:layout_below="@+id/user_name"
       android:text="loication"
       android:textColor="@color/lightred"
       android:textSize="15dp"
       android:textStyle="bold" />

    </RelativeLayout>

       <RelativeLayout
           android:id="@+id/userimage_menu"
           android:layout_width="match_parent"
           android:layout_height="40dp"
              android:background="@drawable/list_selector"
           android:layout_alignParentLeft="true"
           android:layout_below="@+id/userimage_top" >

             <ImageView
        android:id="@+id/icon"
        android:layout_width="25dp"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_marginLeft="12dp"
        android:layout_marginRight="12dp"
        android:contentDescription="@string/desc_list_item_icon"
        androidrc="@drawable/home_icon"
        android:layout_centerVertical="true" />

    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_toRightOf="@id/icon"
        android:minHeight="?android:attr/listPreferredItemHeightSmall"
        android:textAppearance="?android:attr/textAppearanceListItemSmall"
        android:textColor="@color/list_item_title"
        android:gravity="center_vertical"
        androidaddingRight="40dp"/>

    <TextView android:id="@+id/counter"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/counter_bg"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:layout_marginRight="8dp"
        android:textColor="@color/counter_text_color"/>


       </RelativeLayout>

    </RelativeLayout>


<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">


    <!-- Framelayout to display Fragments -->
    <FrameLayout
        android:id="@+id/frame_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />



    <!-- Listview to display slider menu -->
    <ListView
        android:id="@+id/list_slidermenu"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:choiceMode="singleChoice"
        androidivider="@color/list_divider"
        androidividerHeight="1dp"        
        android:listSelector="@drawable/list_selector"
        android:background="@drawable/side_menu_panel"/>
       </LinearLayout>
</android.support.v4.widget.DrawerLayout>

so can any one please help me to solve this problem.

user3737339
  • 231
  • 1
  • 5
  • 11
  • Create another similar XML file, with `ImageView`'s height/width according to your desired image's dimensions. Then in `Adapter`'s `getView` method, set your image to the `ImageView`. – Ammar Jun 30 '14 at 08:54
  • another XML file means how can i show it in the same view sorry i can't get you can u plz show me sample – user3737339 Jun 30 '14 at 08:57
  • Why are you not using `ListView` to achieve the required? – Ammar Jun 30 '14 at 09:29
  • already i'm getting the titles and images in listview only – user3737339 Jun 30 '14 at 11:08
  • The XML layout is you list row layout, right? – Ammar Jun 30 '14 at 11:31
  • yes i'll update my other XML also for your reference now – user3737339 Jun 30 '14 at 11:33
  • See http://stackoverflow.com/questions/4777272/android-listview-with-different-layout-for-each-row – Ammar Jun 30 '14 at 11:41
  • ok let me try it out and know for you.. – user3737339 Jun 30 '14 at 11:43
  • no bro already i'ad tried it can change only specific now i'm going on with other ideas to change the alignment by code wise and let me know for u. – user3737339 Jul 01 '14 at 04:31
  • Before that, have a look at this too. http://stackoverflow.com/questions/13297299/reusing-views-in-android-listview-with-2-different-layouts – Ammar Jul 01 '14 at 04:40
  • yes in code wise i tried with setting the position and change the height and of each rows but now i'm going to set empty linear layout and set the imageview textview alignment by code wise default. – user3737339 Jul 01 '14 at 04:47
  • There can be multiple approaches, but the 2nd link, I mentioned, certainly addresses your issue. – Ammar Jul 01 '14 at 05:10

1 Answers1

0

Finally i'ad acheived it by myself by using the custom ListView in slide bar menu.

user3737339
  • 231
  • 1
  • 5
  • 11