【发布时间】:2016-12-20 23:19:02
【问题描述】:
我有一个 FrameLayout,其中包含一个我正在使用的播放栏,它显示有关音乐播放的信息以及切换。出于某种原因,我无法让框架布局顶部的填充消失。我尝试以编程方式和通过 XML 使所有元素和整个布局的边距/填充为 0dp,但没有任何效果。我假设这只是 FrameLayout 中内置的一些自然行为。我还尝试将 FrameLayout 设置为相同的所需高度(56dp/dimen/playbar_size),但填充仍然存在。
<SeekBar
style="@style/Base.Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/progress"
android:layout_marginLeft="@dimen/playbar_size"
android:layout_marginTop="-8dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginLeft="64dp"
android:orientation="horizontal"
android:layout_gravity="right|bottom">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical"
android:paddingTop="5dp">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#fff"
android:textSize="14dp"
android:singleLine="true"
android:lines="1"
android:maxLines="1"
android:ellipsize="end"
android:textStyle="bold" />
<TextView
android:id="@+id/subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#fff"
android:textSize="12dp"
android:singleLine="true"
android:lines="1"
android:maxLines="1"
android:ellipsize="end"
android:layout_marginLeft="8dp" />
</LinearLayout>
<ImageButton
android:id="@+id/toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:soundEffectsEnabled="false"
android:padding="12dp"
app:srcCompat="@drawable/ic_pause_dark"
android:layout_gravity="bottom"
android:background="@android:color/transparent" />
<ImageButton
android:id="@+id/next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:soundEffectsEnabled="false"
android:padding="12dp"
app:srcCompat="@drawable/quantum_ic_skip_next_white_24"
android:layout_gravity="bottom" />
</LinearLayout>
<ImageView
android:id="@+id/art"
android:layout_width="@dimen/playbar_size"
android:layout_height="@dimen/playbar_size"
android:layout_gravity="left|top"
android:layout_marginTop="0dp" />
</FrameLayout>
所需的视图,没有填充和搜索栏一直到顶部 - 这是它应该是的实际高度。
【问题讨论】:
标签: android xml android-framelayout