简体   繁体   English

在可绘制背景中将ImageButton连接到屏幕边缘

[英]Connect ImageButton to edge of screen in drawable background

Trying to get the top left white space to touch the edge of the screen but can't figure out what I am doing wrong. 试图获取左上角的白色空间以触摸屏幕边缘,但无法弄清楚我在做什么错。 I don't want the green showing on the left, I want the white covering it up. 我不想绿色显示在左边,我希望白色覆盖它。

在此处输入图片说明

BUTTON CODE: 按钮代码:

<ImageView
    android:id="@+id/itempicture"
    android:layout_width="0dp"
    android:layout_height="fill_parent"
    android:layout_weight="2"
    android:background="@drawable/profilepicture" />

DRAWABLE/PROFILEPCTURE_DEFAULT CODE: DRAWABLE / PROFILEPCTURE_DEFAULT代码:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item><shape>
            <gradient android:type="linear" android:angle="270" android:startColor="#FFFFFF" android:centerColor="#FFFFFF" android:endColor="#424242" />

            <stroke android:width="0dp"></stroke>

            <corners android:bottomRightRadius="35dp" />

            <padding android:bottom="5dp" android:left="5dp" android:right="5dp" android:top="5dp" />
        </shape></item>

</selector>

您正在使用左侧的填充,请尝试将其删除。

In your DRAWABLE/PROFILEPCTURE_DEFAULT CODE: 在您的DRAWABLE / PROFILEPCTURE_DEFAULT代码中:

You have the line padding android:bottom="5dp" android:left="5dp" android:right="5dp" android:top="5dp". 您需要填充android:bottom =“ 5dp” android:left =“ 5dp” android:right =“ 5dp” android:top =“ 5dp”。

This puts internal spacing on all sides of your object. 这会将内部间距放置在对象的所有侧面。

Remove to android:left="5dp" to get rid of the spacing on the left. 移至android:left =“ 5dp”摆脱左侧的间距。

To fix this problem I had to change the padding from the LinearLayout holding the object by adding android:paddingLeft="0dp" to LinearLayout xml code in the main. 为了解决这个问题,我不得不通过将android:paddingLeft="0dp"到主要的LinearLayout xml代码中来更改持有对象的LinearLayout的填充。 This is different then changing the padding within the drawable which was the wrong solution. 这与更改可绘制对象内的填充不同,这是错误的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM