首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Android:图像重于图像

Android:图像重于图像
EN

Stack Overflow用户
提问于 2010-09-03 17:29:24
回答 4查看 28.3K关注 0票数 16

我有一个视频缩略图,当你点击它时,视频开始在YouTube播放器中播放。

这是有效的,但不清楚你必须点击缩略图才能播放,因此,我想在右下角的缩略图上绘制一个播放按钮图像。我该怎么做呢?

我目前在可绘制的对象中有缩略图,在可绘制的资源目录中有播放按钮。

我尝试了位图和画布的东西,但这是相当困难的,我不知道这是不是可行的方法。

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2010-09-03 17:36:27

使用Relative或FrameLayout:

代码语言:javascript
复制
   <RelativeLayout 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content">

        <ImageView 
               android:layout_width="wrap_content" 
               android:layout_height="wrap_content"
               android:src="@drawable/thumbnail"/>
        <ImageView  
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:src="@drawable/play" 
               android:layout_alignParentBottom="true"
               android:layout_alignParentRight="true"/>

    </RelativeLayout>

代码语言:javascript
复制
<FrameLayout
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content">

      <ImageView 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content"
           android:src="@drawable/thumbnail"/>

      <ImageView 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:src="@drawable/play" 
           android:layout_gravity="bottom|right"/>

</FrameLayout>
票数 35
EN

Stack Overflow用户

发布于 2010-09-03 17:35:23

如果使用FrameLayoutRelativeLayout来堆叠视图呢?

下面是一些psaudo代码:

代码语言:javascript
复制
<FrameLayout
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
>
<com.yourpackage.VideoPlayer
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
></VideoPlayer>

<!-- Adjust the layout position of the button with gravity, margins etc...  -->
<Button
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_gravity="bottom"
 android:text="Play"
/>

</FrameLayout>
票数 4
EN

Stack Overflow用户

发布于 2017-03-10 22:40:50

我使用了RelativeLayout,它对我很有效

代码语言:javascript
复制
<RelativeLayout
    android:id="@+id/image_container"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <android.support.v7.widget.AppCompatImageView
        android:id="@+id/image"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scaleType="fitXY"
        android:adjustViewBounds="true"
        android:clickable="true"
        android:layout_gravity="top"
        android:maxHeight="400dp"/>

    <ImageView
        android:id="@+id/play"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/ic_menu_play_large"
        android:layout_centerInParent="true" />

</RelativeLayout>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3634496

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档