android - 如何在全 View 中显示图像

标签 android android-imageview android-scrollview

我有一张图片,我需要它以完整 View 显示。但是图像在加载后显示在手机中会被缩小以适合屏幕。如何按原样包含完整尺寸和分辨率的图像,以便可以滚动查看宽度?

这是我的布局文件:

<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="#EEEEEE">

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
 android:scrollbars="vertical" 
 android:layout_height="wrap_content" 
 android:layout_width="fill_parent"
 android:background="#77aa88">

<LinearLayout 
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:background="#FFFFFF">

<TextView   android:text="Xkcd"
        android:textColor="#6E7B91"
        android:textSize="28dp"
        android:textScaleX="1.8"

        android:id="@+id/TextHead" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:paddingTop="10dp"
        android:paddingBottom="10dp"
        android:gravity="center" />

<TextView   android:text="A webcomic of romance, sarcasm, math, and language."
        android:textColor="#000000"
        android:textSize="15dp"
        android:textScaleX="1.1"
        android:id="@+id/TextSub" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:paddingTop="5dp"
        android:paddingBottom="10dp"
        android:gravity="center" />
</LinearLayout>
</ScrollView>

<ScrollView 
 android:scrollbars="horizontal" 
 android:layout_height="match_parent" 
 android:layout_width="wrap_content">

        <ImageView  android:id="@+id/MainImage" 
                    android:layout_width="fill_parent" 
                    android:layout_height="fill_parent"/>


</ScrollView>

</LinearLayout>

最佳答案

尝试使用矩阵 scaleType :

<ImageView  android:id="@+id/mainimage" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"
            android:src="@drawable/mainimage"
            android:scaleType="matrix"/>

关于android - 如何在全 View 中显示图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4407797/

相关文章:

android - 在通话中播放音频,以便另一端可以听到

android - 没有网络连接

带有叠加层的 Android 可缩放/可滚动 ImageView

android - 为什么 Fragment 的 ScrollView 中的 LinearLayout 是 NULL 对象?

android - 当许多在层次结构中时,Espresso 匹配第一个元素

Android 应用内计费 : If in app purchase is controlled by primary device account then how to prevent passing accounts

android - 单击放大 ImageView

android - ImageView 旋转

android - ScrollView 不显示整个 TableLayout

android - 无法将页脚添加到 ScrollView - android