首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >安卓RelativeLayout stretch背景

安卓RelativeLayout stretch背景
EN

Stack Overflow用户
提问于 2016-08-09 13:41:14
回答 3查看 260关注 0票数 1

全。这是我的布局代码:

代码语言:javascript
运行
复制
    <?xml version="1.0" encoding="utf-8"?>
    <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"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:background="@mipmap/backgroung"
    tools:context=".MainScreen">


    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="30pt"
        android:text="@string/level1"
        android:onClick="@string/level1"
        android:id="@+id/level1"/>
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="60pt"
        android:text="@string/level2"
        android:id="@+id/level2"/>
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="90pt"
        android:text="@string/level3"
        android:id="@+id/level3"/>

它看起来像是:

我想让打孔机的照片在整个白色背景上展开。

感谢你的帮助!

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2016-08-09 17:03:58

我明白了,当添加新的图像资源时,它会调整图像的大小并裁剪成白色边框。需要硬拷贝-将整个照片粘贴到可绘制文件夹。

票数 1
EN

Stack Overflow用户

发布于 2016-08-09 13:49:22

最好在这里使用9patch镜像。其中打孔面积可以是恒定的,并且图像可以随着蓝色区域而伸展。这样你就不会面临图像因拉伸而变得模糊的问题。你可以找到一些很好的例子,教你如何在youtube上创建9补丁。这是一个sample

票数 1
EN

Stack Overflow用户

发布于 2016-08-09 14:13:23

在你的RelativeLayout中,你看到那些android:paddingTop和下/左/右了吗?删除所有这些或更改为="0dp"

将您的图像移动到<ImageView/>中按钮之前。

并使用android:scaleType="fitXY"

哦,确保你的图片没有任何空白边框。

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

https://stackoverflow.com/questions/38842873

复制
相关文章

相似问题

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