Android 显示的横向 ImageView

Android displayed of a landscape ImageView

我有一个问题。我使用 Android Studio 进行开发。 我有一个像这样的非常漂亮的风景图像视图<3: http://www.barrymellorphotography.co.uk/assets/Uploads/landscapes-13.jpg

我想在 phone 上显示它(无论是横向还是纵向),以便它占用整个父布局宽度,并占用必要的高度大小(按比例)。但是我没有达到这个目标:(

首先显示的图片质量比我要导入的图片差很多:我想是因为Android Studio 将它缩小到不同的文件夹(hdpi、mdpi...)在小图片的质量之后,它扩展到 phone!

其次它不占据整个宽度...在左侧和右侧保持 2 或 3 dps!并且高度最小(1dp)并且不成比例:(

下面我解释一下我是如何导入和显示图片的,如果有人有答案,谢谢!


1- 我点击新图片资源!

2- 在我选择的资产工作室中:

我点击确定 => 图片发送到 mipmap 文件夹

3- 在显示它的 activity XML 文件中,我这样做:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:background="@color/bleuclair"
    tools:context=".Aproposde">


    <ImageView
        android:id="@+id/aproposdebanniere"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scaleType="fitCenter"
        android:background="@mipmap/banniere"/>


</RelativeLayout> 

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

阅读 Android 使用的不同类型的音阶类型。 fitCenter 将缩放您的图像。尝试 centerInside。这似乎更符合您的要求。

不要使用图像资源工具,它只适用于图标。 只需将 jpg 放入 res/drawable 文件夹(如果不存在,请创建 drawable 文件夹),然后像下面这样更改 ImageView。

<ImageView
    android:id="@+id/aproposdebanniere"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:src="@drawable/landscape"/>