如何在Android中将SeekBar放置在ImageView上方?

4

您好,

我在Android中有以下布局。我想让seekbar显示在图像的顶部(我有一些代码可以使其可见和不可见(或者说GONE)。

我想知道是否有人能告诉我如何定位它,以便seekbar覆盖imageview,从而允许imageview占据整个屏幕。

谢谢

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<.imageOverlay android:id="@+id/surface"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" />

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

<SeekBar
 android:id="@+id/seekbar"
 android:layout_width="100px"
 android:layout_height="wrap_content"
 android:layout_gravity="center_horizontal"
 android:max="255"/>

<ImageView
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:id="@+id/surfaceimage"
 android:scaleType="fitXY"
  />


1
你关闭了LinearLayout和RelativeLayout标签吗? - Anthony Forloney
已经通过以下方法使其工作正常。 - Steve
1个回答

3

我用以下方法让它工作了 - 我使用了帧布局而不是线性布局。

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<.imageOverlay android:id="@+id/surface"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" />


<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"     android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>

<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
 android:id="@+id/surfaceimage"
 android:scaleType="fitXY"
  />
  <SeekBar
android:id="@+id/seekbar"
android:layout_width="100px"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:max="255"/>


</FrameLayout>
</RelativeLayout>


`.imageOverlay是什么鬼? - Hugo M. Zuleta
1
嗨@HugoM.Zuleta - 它是Android 1.6中SDK的一部分。自那以后我就没有编写过任何Android程序,所以根据您的回复,我猜它已经不存在了 :-) p.s 这个问题已经有7年了。 - Steve
感谢回复,翻译的内容很有意义。 - Hugo M. Zuleta

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接