简体   繁体   English

Android ImageView在图像周围添加了空白(尝试修复此问题并不算幸运)

[英]Android ImageView adds white space around image (tried fixes on here an no luck)

I am creating an android start screen which has an image inside an ImageView. 我正在创建一个Android的开始屏幕,其中在ImageView中有一个图像。

The image i have put inside the image view is 75x75 pixels without any white space (see below). 我放入图像视图内的图像是75x75像素,没有任何空白(请参阅下文)。

I have attempted to set the background to transparent/black/remove layout padding and still no luck. 我试图将背景设置为透明/黑色/删除布局填充,但仍然没有运气。

Image i am using: 我正在使用的图像:

我正在使用的图像没有背景

the results of my xml file for activity_start_screen.xml 我的activity_start_screen.xml xml文件的结果

开始画面结果

Here is my current xml for the screen in question, i am capable in Java but first time doing android so i don't know all the tips and tricks just yet! 这是我当前正在讨论的屏幕的xml,我能够使用Java,但是第一次使用android,所以我还不了解所有提示和技巧!

XML: XML:

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/startScreenRelLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/black"
    tools:context=".StartScreen" >

    <Button
        android:id="@+id/startCreateWalkButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true"
        android:layout_below="@+id/logoImageView"
        android:text="@string/startCreateButtonText" />

    <Button
        android:id="@+id/startEditWalkButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/startCreateWalkButton"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="@string/startEditButtonText" />

    <ImageView
        android:id="@+id/logoImageView"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="114dp"
        android:adjustViewBounds="false"
        android:background="@color/black"
        android:contentDescription="@string/logoText"
        android:src="@drawable/logo" />

</RelativeLayout>

There is no code in the java file just yet, im just creating the layout or should i do image adding/color setting using java code. Java文件中还没有代码,我只是创建布局,还是应该使用Java代码进行图像添加/颜色设置。

the color black is set as #000000 so it is indeed black 黑色设置为#000000,因此它确实是黑色

您需要使用.png图片而不是其他格式。

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

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