android - 在网格布局中并排调整和缩放两个图像

标签 android image layout grid scale

我有两张图片——左边是播放按钮,右边是音箱。我正在尝试缩放这些图像的高度和宽度,使其看起来像这样

enter image description here

虽然我的代码产生了这个:

enter image description here

本质上,文件很大而且大小不正确,但我不知道为什么 boombox 图像被截断了。我想要整个音箱适合,然后播放按钮根据音箱的高度调整其高度。

这是我的布局代码,但我认为我需要进行大的更改:

<GridLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal"
    android:stretchMode="columnWidth"
    android:numColumns="2"
    android:scaleType="fitXY"

    >

    <ImageView
        android:id="@+id/play_stop_button"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_column="0"
        android:src="@drawable/play_button_final"
        />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:layout_column="1"
        android:scaleType="fitXY"
        android:src="@drawable/boombox"
        android:id="@+id/boombox"
        />


</GridLayout>

最佳答案

试试这个,

<GridLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal"
    android:stretchMode="columnWidth"
    android:numColumns="2"
    android:scaleType="fitXY"

    >

    <ImageView
        android:id="@+id/play_stop_button"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_column="0"
        android:src="@drawable/play_button_final"
        />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:adjustViewBounds="true"
        android:layout_column="1"
        android:scaleType="fitXY"
        android:src="@drawable/boombox"
        android:id="@+id/boombox"
        />


</GridLayout>

关于android - 在网格布局中并排调整和缩放两个图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31034185/

相关文章:

html - 如何透明去除图像阴影

c# - 在 WPF 中平滑图像边缘

Java Swing : manage multiple SpringLayout

java - Eclipse 不会创建 JLabels

arrays - 使用 Julia 中的 Images 导出图像

css - 为什么这个 CSS 没有占据整个页面?

android - 表格布局环绕文本android

android - 如何检查外部存储空间的可用性?

java - Android 在随机位置以随机大小绘制随机圆圈

android - 如何动态更改Modal Bottomsheet android中的内容