Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/224.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何在幻灯片菜单中显示个人资料图片?_Android_Menu - Fatal编程技术网

Android 如何在幻灯片菜单中显示个人资料图片?

Android 如何在幻灯片菜单中显示个人资料图片?,android,menu,Android,Menu,我将继续我的菜单滑动条操作,为此,我在谷歌上搜索并通过下面的链接完成了我的滑动条操作 现在我需要的是添加一个个人资料图像和用户名,并将他的位置(例如:图像,约翰,钦奈)放在列表的顶部。 我尝试为上面三个项目创建单独的相对布局,为其余列表项创建另一个单独的布局,但我遇到了一些对齐问题 以下是我的布局: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.an

我将继续我的菜单滑动条操作,为此,我在谷歌上搜索并通过下面的链接完成了我的滑动条操作

现在我需要的是添加一个个人资料图像和用户名,并将他的位置(例如:图像,约翰,钦奈)放在列表的顶部。 我尝试为上面三个项目创建单独的相对布局,为其余列表项创建另一个单独的布局,但我遇到了一些对齐问题

以下是我的布局:

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


因此,任何人都可以帮助我解决这个问题。

最后,我通过使用滑动条菜单中的自定义ListView实现了这一点。

创建另一个类似的XML文件,使用
ImageView
的高度/宽度,根据所需图像的尺寸。然后在
Adapter
getView
方法中,将图像设置为
ImageView
。另一个XML文件意味着我如何在同一视图中显示它抱歉,我无法获取您可以给我显示示例为什么您不使用
ListView
来实现所需的功能?我已经在ListView中仅获取标题和图像了XML布局是您的列表行布局,对吗?