在网格布局中并排放置和缩放两个图像

时间:2015-06-24 18:26:24

标签: android image layout grid scale

我有两张图片 - 左边是播放按钮,右边是扬声器。我试图将这些图像的高度和宽度缩放为这样

enter image description here

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

enter image description here

基本上,这些文件非常大,而且尺寸不正确,但我不知道为什么音箱图像会被切断。我希望整个音箱适合,然后根据音箱的高度调整播放按钮。

这是我的布局代码,但我认为我需要做出重大改变:

<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>

1 个答案:

答案 0 :(得分:1)

试试这个,

<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>
相关问题