首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在nexus 5 android中压缩背景图像。

在nexus 5 android中压缩背景图像。
EN

Stack Overflow用户
提问于 2015-12-03 18:01:24
回答 1查看 517关注 0票数 0

我有一个大小相当于Nexus-5维(1080×1920像素)的飞溅屏幕的图像。现在,当我在LinearLayout的背景中添加这个图像时,它似乎被压缩了,下面是代码

代码语言:javascript
复制
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:orientation="vertical" android:layout_width="fill_parent"
          android:background="@drawable/app_bg"
          android:layout_height="fill_parent">

           <!-- 
              <ImageView android:id="@+id/splash_screen" 
               android:layout_width="fill_parent"
               android:layout_height="fill_parent"
               android:background="@drawable/app_bg"
               android:layout_gravity="center"/>
           -->

     </LinearLayout>

真实形象是

附件是附件5的屏幕截图。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-12-03 18:27:42

为了将图像设置为背景,您应该使用下面的图像视图,并为此使用android:scaleType="centerCrop"和框架布局。

代码语言:javascript
复制
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<ImageView 
    android:id="@+id/background"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scaleType="centerCrop">
</ImageView>  

谢谢

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34073064

复制
相关文章

相似问题

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