java - ImageView 不包装内容

标签 java android imageview

我有一个 ImageView 包装 this image :

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

在它的正下方,一个TextView。不幸的是,它会根据设备的屏幕尺寸将其推下 View 或移出 View 。

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

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

我可以“破解”它,但它宁愿不...

<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:

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

关于java - ImageView 不包装内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21203189/

相关文章:

android - 更改 imageView 的枢轴

java - 使用 Sonar 检测测试中的重复代码

java - Android 从隐式 Intent 中获取 .txt 文件

Android:显示可变图像

android - 如何使用 PDFBox for Android 从 tiff 图像创建 pdf?

android - 如何在 Android 的全屏模式下访问视频对象

android - 下一张和上一张图片通过滑动 s

java - 覆盖 struts 2 拦截器

java - Jersey /Jax-RS : how to filter resource and sub-resources

java - 业务层 Jersey 的基本依赖注入(inject)