2

我想使用小于屏幕宽度但高度大于屏幕的图像。我正在考虑使用滚动视图,可以使用整个图像,但拟合会改变图片的原始比例。如何以相同的比例调整宽度和增加高度?这是代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:background="@drawable/tutorial"
  > 
  <ScrollView
    android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
  <ImageView
    android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:scaleType="fitXY"
  android:src="@drawable/tutorial">
  </ImageView>
  </ScrollView>   
</LinearLayout>
4

2 回答 2

1

你不使用fill_parent你想使用match_parent

<ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:backround="@drawable/tutorial"/>

于 2013-02-08T04:06:17.867 回答
0

android:scaleType="CENTER_INSIDE"在你的Imageview就是它。

有关更多详细信息 ,请在此处阅读有关 CENTER_INSIDE的更多信息

于 2013-02-08T03:52:29.150 回答