我正在创建一个 Android 开始屏幕,其中 ImageView 中有一个图像。
我放入 ImageView 中的图像为 75x75 像素,没有任何空白(见下文)。
我尝试将背景设置为透明/黑色/删除布局填充,但仍然没有成功。
我正在使用的图像:
activity_start_screen.xml 的 xml 文件的结果
这是我当前有关屏幕的 xml,我能够使用 Java,但第一次使用 Android,所以我还不知道所有的提示和技巧!
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>
java 文件中还没有代码,我只是创建布局,或者我应该使用 java 代码进行图像添加/颜色设置。
黑色被设置为#000000,所以它确实是黑色
最佳答案
您需要使用.png
图像而不是其他格式。
关于java - Android ImageView 在图像周围添加空白(尝试修复此处但不成功),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20129095/