【问题标题】:Image not getting displayed properly on splash screen in android图像无法在 android 的初始屏幕上正确显示
【发布时间】:2016-12-16 16:36:18
【问题描述】:

我正在为我的应用程序设计一个启动画面,但我用于它的图像没有正确显示。我附上了我正在使用的图片以及它是如何在此处显示的,以及初始屏幕的 .xml 文件的代码。

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00abd4" >

<ImageView
    android:id="@+id/imgLogo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:src="@drawable/logo1" />

Picture I am using

How it's getting displayed

【问题讨论】:

  • 尝试将android:layout_widthandroid:layout_height 设置为match_parent
  • 你在哪个drawable文件夹里?
  • @Stefan drawable里面有一个文件夹,里面有4种尺寸的图片。
  • @Lal 也没有使用它
  • 在 mdpi - hdpi - xhdpi - xxhdpi 中?因为如果你只使用默认的可绘制地图,它会被缩放,可能太大

标签: android android-layout splash-screen


【解决方案1】:
<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00abd4" >

<ImageView
    android:id="@+id/imgLogo"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_centerInParent="true"
    android:src="@drawable/logo1" />

【讨论】:

  • 如果你只使用你在 xml 中提供的这么多行代码,那么它会起作用,如果你有更多的东西在它下面。检查...
  • 这是启动画面的整个 xml 代码。最后加上RelativeLayout的结束标签即可。
  • 那么你的图片就小了,
  • android:background="@drawable/logo1"
  • 好的。让我试试这个。此外,图片的分辨率为 1600x900 像素
猜你喜欢
  • 2020-01-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-03-04
  • 1970-01-01
  • 1970-01-01
  • 2019-03-07
  • 1970-01-01
相关资源
最近更新 更多