【发布时间】:2016-07-18 20:33:21
【问题描述】:
我进行了多次搜索,但似乎没有任何方法可以避免我的横幅被拉伸。 我在可绘制文件夹中保存了横幅的多个实例。图片的宽度为:
- xxhdpi: 1440px
- xhdpi: 960px
- hdpi: 720px
- mdpi:480px
当我在屏幕宽度为 1080 像素的设备上运行应用程序(例如,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>
感谢您的帮助!
【问题讨论】:
标签: android imageview aspect-ratio stretch