Android ImageView 拉伸图像
Android ImageView stretches image
我搜索了又搜索,似乎没有任何方法可以避免我的横幅拉伸。
我在可绘制文件夹中保存了横幅的多个实例。图片的宽度为:
- xxhdpi: 1440px
- xhdpi: 960px
- hdpi: 720px
- mdpi:480px
当我 运行 在屏幕宽度为 1080px 的设备(例如 nexus 5)上使用该应用程序时,图像会被拉伸..
我使用的布局是垂直线性布局,图像视图中的横幅位于顶部。
我试过更改 scaleType、layout_width/height 和 adjustViewBounds 属性,但似乎没有任何效果..
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity"
android:orientation="vertical"
android:baselineAligned="false"
android:background="@drawable/smos_bg"
android:padding="0dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
android:background="@drawable/top" />
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="none"/>
</LinearLayout>
感谢您的帮助!
试试这个:
<ImageView
android:id="@+id/imageId"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/top" >
</ImageView>
我搜索了又搜索,似乎没有任何方法可以避免我的横幅拉伸。 我在可绘制文件夹中保存了横幅的多个实例。图片的宽度为:
- xxhdpi: 1440px
- xhdpi: 960px
- hdpi: 720px
- mdpi:480px
当我 运行 在屏幕宽度为 1080px 的设备(例如 nexus 5)上使用该应用程序时,图像会被拉伸..
我使用的布局是垂直线性布局,图像视图中的横幅位于顶部。 我试过更改 scaleType、layout_width/height 和 adjustViewBounds 属性,但似乎没有任何效果..
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity"
android:orientation="vertical"
android:baselineAligned="false"
android:background="@drawable/smos_bg"
android:padding="0dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
android:background="@drawable/top" />
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="none"/>
</LinearLayout>
感谢您的帮助!
试试这个:
<ImageView
android:id="@+id/imageId"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/top" >
</ImageView>