我正在尝试创建一个充当小型媒体播放器的叠加层。
我已经创建了一个新的Activity,它使用了一个让它的背景透明(深透明)的主题。Android:LinearLayout叠加尽可能小
但是我在布置时遇到了问题。
将覆盖目前看起来像这样:
我试图让媒体播放盒(白方)垂直居中和(垂直)尽可能小。 我目前正在试图通过让一个LinearLayout中的两个空白View包围Box的布局来实现此目的。
当前代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#CCFFFFFF"
android:id="@+id/overlay_layout" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/overlay_firstrow">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/overlay_playbutton"
android:src="@android:drawable/ic_media_play"
android:background="@null" />
<SeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/overlay_seekbar" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/overlay_firstrow"
android:layout_alignParentLeft="true"
android:id="@+id/overlay_text"
android:text="filename" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
我知道,当前的代码不工作(因为我分配的两个空白视图和LinearLayout中的权重1 - 所以中间箱占据了屏幕的确切三分之一身高)
但我不知道如何正确地做到这一点。 我的目标是中间的盒子尽可能小,而两个外部(空白)视图占用相等部分的剩余空间。
我希望有人能帮助我实现这一点。
由于提前,
乌列尔
尝试删除'机器人:layout_weight = “1”'从RelativeLayout的 – Merlevede
现在相对布局(中间盒)占据了所有的空间。 (水平和垂直拉伸) – Ansgar