首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >分辨率相同的图像不适合于布局图像视图

分辨率相同的图像不适合于布局图像视图
EN

Stack Overflow用户
提问于 2015-12-02 13:10:18
回答 3查看 147关注 0票数 0

问题:试图为一个简单的布局提供多设备支持屏幕,但在Nexus 6中它造成的问题,意味着不显示适合。它的另一面是减少nexus-6分辨率的文档为1440*2560的地方,图像应该是可绘制的-xxxhdpi .so i保持一个分辨率为1440*2560的图像。

代码语言:javascript
复制
<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">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/icon"
        android:id="@+id/imv" />
</RelativeLayout>

如果我给出这样明显的match_parent,它将扩展图像。请帮我摆脱这一切。这是屏幕截图-

layout.png

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2015-12-02 13:49:17

将图像的宽度设置为fill_parent (如果您想要稍微小一点的imageView,也可以设置固定的宽度)

使用android:调整视图栏以保持高宽比

将高度设置为wrap_content (保持高宽比所需的一切)

代码语言:javascript
复制
<ImageView
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:adjustViewBounds="true"
       android:src="@drawable/icon"
       android:id="@+id/imv"
       android:scaleType="fitCenter" />
票数 0
EN

Stack Overflow用户

发布于 2015-12-02 13:13:18

如果要在图像视图上匹配图像,请在xml代码中的imageview中将android:src替换为android: ImageView背景。

票数 0
EN

Stack Overflow用户

发布于 2015-12-02 13:14:02

尝试在布局中使用这些代码行

代码语言:javascript
复制
 <ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/icon"
    android:scaleType="fitXY"
    android:id="@+id/imv" />
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34043611

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档