图像视图不包装内容 [英] Image View not Wrapping Contents

查看:129
本文介绍了图像视图不包装内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含此图片的ImageView:

I've got an ImageView wrapping this image:

<ImageView
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:scaleType="fitStart"
    android:src="@drawable/oncmap"/>

正下方是TextView。不幸的是,它要么根据设备的屏幕尺寸将其推向视图或从视图中移出。

and right below it, a TextView. Unfortunately, it either pushes it down the view or out of the view depending on the device's screen size.

http://i.imgur.com/CuVFK5P.png

http://i.imgur.com/6wzMebV.jpg

我可以破解它,但它不是......

I can "hack" it, but it'd rather not...

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="16dp"
android:orientation="vertical"
tools:context="MapFragment">

<ImageView
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:src="@drawable/oncmap"/>

<TextView
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:text="Neptune"
    style="@style/sectionHeader"/>

<TextView
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:paddingLeft="8dp"
    android:paddingRight="8dp"
    android:paddingTop="16dp"
    android:text="@string/info"
    style="@style/text"/>

推荐答案

将以下字段添加到ImageView:

Add the following fields to ImageView:

android:scaleType="fitXY"
android:adjustViewBounds="true"

这篇关于图像视图不包装内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆