代码之家  ›  专栏  ›  技术社区  ›  Sasha Shpota A-Bag

ExoPlayer:删除播放按钮和时间线行之间的冗余空间

  •  6
  • Sasha Shpota A-Bag  · 技术社区  · 6 年前

    以下是我要删除/缩小的内容(用红色突出显示):

    enter image description here

    paddingTop , layout_marginTop layout_height 参数(以前更大)。

    但这还不够,还需要很大的空间。

    问题: 如何缩小图片上的空白区域?

    exo_player_control_view.xml 看起来像(为了简单起见删除了大部分元素):

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:background="#CC000000"
        android:layoutDirection="ltr"
        android:orientation="vertical">
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:orientation="horizontal">
            <ImageButton
                android:id="@id/exo_play"
                style="@style/ExoMediaButton.Play" />
        </LinearLayout>
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_vertical"
            android:orientation="horizontal">
            <com.google.android.exoplayer2.ui.DefaultTimeBar
                android:id="@id/exo_progress"
                android:layout_width="0dp"
                android:layout_height="18dp"
                android:layout_weight="1" />
        </LinearLayout>
    
    </LinearLayout>
    

    我完全理解缩小这些区域可能会降低控制面板的可用性。没关系。我想至少有能力改变它们,并测试它是如何工作的。

    1 回复  |  直到 6 年前
        1
  •  7
  •   Ashwini Violet    6 年前

    首先你要做的是定义的高度和宽度 ImageButton wrap_content 所以它可以正常工作。 播放按钮上方的填充是由于缺少高度和宽度

    app:touch_target_height 这个高度增加了播放按钮和时间之间的间隔酒吧。这个高度是内栏的触摸区域,你可以用它来增加用户的触摸区域而不增加栏的大小,这看起来像是填充。制造尺寸 0dp 填充物就会消失

    还有一个填充是图像填充。我从 exoPlayer 我发现这个图像也有一些默认的填充。如果你想删除这个填充,然后改变这个图像。

    也可以使用 app:bar_height 但是记住 应用:酒吧高度 不能交叉 应用程序:触摸目标高度 . 即使你给它下了更多的定义 #9e0c26 )

    here

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    
    
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:background="#CC000000"
        android:layoutDirection="ltr"
        android:orientation="vertical">
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:orientation="horizontal">
    
            <ImageButton
                android:id="@id/exo_play"
                style="@style/ExoMediaButton.Play"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
        </LinearLayout>
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_vertical"
            android:orientation="horizontal">
    
            <com.google.android.exoplayer2.ui.DefaultTimeBar
                android:id="@id/exo_progress"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:bar_height="2dp"
                app:touch_target_height="2dp" />
        </LinearLayout>
    
    </LinearLayout>