【问题标题】:How to momentarily change the width of a layout object?如何暂时更改布局对象的宽度?
【发布时间】:2013-12-12 08:10:30
【问题描述】:

我有一个布局 XML,其中包含一个带有 videoview 的 framelayout,以及另一个包含 imageview 的 framelayout。带有 videoview 的框架布局按内容包装宽度。我还需要用 imageview 来改变其他框架布局。所以当 videoview 加载时,它应该改变 framelayout 的尺寸。

有什么解决办法吗?我试过addOnLayoutChangeListener,但变化不是立竿见影的。

【问题讨论】:

  • 带有imageview的framelayout的宽度也是wrap_content?
  • 好吧 videoview 和 imageview 的宽度是不同的,我需要以某种方式使 imageview 的宽度依赖于 videoview 的宽度。

标签: android android-layout android-imageview android-videoview android-framelayout


【解决方案1】:

这应该很简单。试试这样的。

  1. 使用一个 LinearLayout。

  2. 添加视频视图和 ImageView 初始化。

  3. 宽度为 0dp 且 layout_weight 为 1 且 ImageView 宽度为 wrap_content(或其他)的视频视图。

  4. 在 Video View 上获取 Video Loaded 事件并简单地使 ImageView Visibility GONE 消失。

    例如。

    <LinearLayout
       android:layout_width="fill_parent"
       android:layout_height="fill_parent"
       android:orientation="horizontal" >
    
        <VideoView android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:layout_weight="1"/>
    
        <ImageView android:layout_width="100dp"
            android:layout_height="fill_parent" />
    </LinearLayout>
    

【讨论】:

  • 问题是图片应该对应videoview的宽度进行缩放
  • 没有得到你想要做的事情。如果可能的话,请解释得更详细一些。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-07-24
  • 1970-01-01
相关资源
最近更新 更多