0

我正在 android studio 中制作音乐播放器,我想做这样的事情

这是我正在尝试做的一个丑陋的画

黑色矩形是电话。我已经制作了黄色部分,现在我必须将 imageview 设置为绘图中的那个,但我不明白我必须输入什么样的属性。

这是我制作的代码:

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

<include
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    layout="@layout/song"
    android:layout_gravity="top" />

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/img_album_cover"
    android:layout_gravity="center" />

<include
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    layout="@layout/song_playback_buttons"
    android:layout_gravity="bottom"/>

</LinearLayout>

提前谢谢你,对不起我的英语不好(我是意大利人)。

4

1 回答 1

0

首先,您将希望它填充顶部和底部布局之间的空间,因此将 ImageView 的宽度/高度设置为 fill_parent。

接下来,您还想给它一个android:layout_weight="1",所以它不会将底部布局推离屏幕。

现在对于实际图像,您需要添加android:scaleType="centerCrop"到 ImageView。这将导致源图像被缩放(从中心,保持纵横比),以便图像的宽度/高度将填充或延伸到视图的边界之外。

编辑:您还可以删除所有 layout_gravity 属性,因为 layout_weight 会使它们变得无用。

于 2016-03-08T22:20:52.347 回答