【问题标题】:Positioning mediacontroller at bottom of listview将媒体控制器定位在列表视图的底部
【发布时间】:2014-05-09 22:37:13
【问题描述】:

如何将媒体控制器定位在列表视图的底部,就像附加的图像一样?媒体控制器应显示在列表末尾。我根本没有显示控制器。这是我的 xml 文件:

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

【问题讨论】:

    标签: android listview mediacontroller


    【解决方案1】:
    1. 您的父 LinearLayout 未指定方向。

    2. 在您的 lv_song_list 中,您将宽度设置为 0dp,将高度设置为 match_parent。你应该切换那些。

    3. 你的 sideIndex 也完全放错了地方。从理论上讲,它将放在您的列表和媒体控制器之间。但是由于高度设置为 match_parent 无论如何它都会搞砸整个事情。

    我认为您需要更多类似的东西,尽管我认为您的 MediaController 不应该包含在 LinearLayout 中。 (删除了除布局和 ID 之外的所有内容。)

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

    【讨论】:

    • 关注了这个,但媒体控制器仍然不可见。 :(
    • 媒体控制器默认不显示,仅在与链接的 VideoView 交互时显示。
    • 我认为您需要的不是 MediaController,而是一个可以控制 MediaPlayer 的自定义视图。由于从示例图像的外观来看,您正在尝试播放音频。
    • 但是应该有一些方法可以像附加的图像一样显示它?
    • 是的,我正在尝试播放音频。不使用自定义视图,就没有办法显示吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-16
    • 1970-01-01
    相关资源
    最近更新 更多