0
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:scaleType="fitXY"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:padding="5dip">

    <ImageView android:id="@+id/header"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:src="@drawable/green_bg" />

</RelativeLayout>

这是我的页眉布局,我需要将图像拉伸到如下所示。 http://postimage.org/image/gfebtdxgj/

  1. 如何在图像上方添加左右两个按钮。
  2. 如何拉伸标题图像。
4

2 回答 2

0

可能的重复:

android:在imageview中拉伸图像以适应屏幕

Android 文档http://developer.android.com/reference/android/widget/ImageView.ScaleType.html

于 2012-10-01T13:52:11.277 回答
0

将此代码用于您的两个问题:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:scaleType="fitXY"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dip">
<Button
    android:id="@+id/btn1"
    android:layout_width="100dp"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    />
<Button
    android:id="@+id/btn2"
    android:layout_width="100dp"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    />
<ImageView android:id="@+id/header"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:src="@drawable/green_bg"
    android:scaleType="centerCrop"
    android:layout_below="@id/btn1"/>

 </RelativeLayout>
于 2018-09-17T05:41:32.687 回答