0

imageHow to position mediacontroller at the bottom of listview like the image attached? The media controller should be shown at the end of list. I am not getting the controller displayed at all. Here is my xml file :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<ListView
    android:id="@+id/lv_song_list"
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:fastScrollEnabled="true" >
</ListView>

<LinearLayout
    android:id="@+id/sideIndex"   /// for alphabet indexer
    android:layout_width="40dip"
    android:layout_height="fill_parent"
    android:background="#FFF"
    android:gravity="center_horizontal"
    android:orientation="vertical" >
</LinearLayout>

    <LinearLayout              // for media controller
    android:id="@+id/footer_layout1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:gravity="center"
    android:layout_gravity="center">

        <MediaController
            android:id="@+id/mediaController1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >
        </MediaController>

</LinearLayout>

 </LinearLayout>![image][2]
Siju
  • 2,585
  • 4
  • 29
  • 53

1 Answers1

0
  1. Your parent LinearLayout doesn't specify an orientation.

  2. On your lv_song_list you set the width to 0dp and the height to match_parent. You should switch those.

  3. Your sideIndex is totally in the wrong place too. Theoretically it will be put between your list and mediacontroller. But since the height is set to match_parent it will screw the whole thing up anyway.

I think you need something more like this, although I don't think your MediaController should be wrapped in a LinearLayout. (Removed everything except for layout and ids.)

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:orientation="horizontal" >

        <ListView
            android:id="@+id/lv_song_list"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="match_parent"/>

        <LinearLayout
            android:id="@+id/sideIndex"
            android:layout_width="40dp"
            android:layout_height="match_parent"
            android:orientation="vertical"/>

    </LinearLayout>

    <LinearLayout android:id="@+id/footer_layout1" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <MediaController
            android:id="@+id/mediaController1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

    </LinearLayout>

</LinearLayout>
Siebe
  • 942
  • 2
  • 10
  • 27
  • Followed this but still mediacontroller not visible. :( – Siju May 09 '14 at 14:27
  • A mediacontroller is not shown by default and is only displayed when interacting with for example the linked VideoView. – Siebe May 09 '14 at 14:33
  • I think the thing you need isn't a MediaController but just a custom view that will control a MediaPlayer. Since by the looks of your example image, you're trying to play audio. – Siebe May 09 '14 at 14:35
  • But there should be some way to display it like the image attached? – Siju May 09 '14 at 14:35
  • Ya I am trying to play audio. Without using a custom view, isn't there a way to display it ? – Siju May 09 '14 at 14:47
  • The MediaController is just a basic view with play/pause, previous, next and a seek bar. There is no support for shuffle, albumart, ... If you really want to use MediaController, I suggest you take a look here about providing a custom view to the MediaController. http://stackoverflow.com/questions/2044000/change-style-of-android-mediacontroller – Siebe May 12 '14 at 07:18