【发布时间】:2017-12-14 18:04:41
【问题描述】:
这太荒谬了,没有错误,我已经在其他一些项目上做过同样的事情并且工作正常,但它仍然什么也没显示...... 有人知道为什么我的背景图像在编辑器中很好(在 Android Studio 编辑器中它显示背景图像),但是当我在设备上运行应用程序时,它显示只有我的 2 个按钮的唯一白色背景......
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.ale.mediaspectrumplayer.MainActivity"
android:background="@drawable/background">
<Button
android:id="@+id/ID_MediaPlayer_Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="48dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="24dp"
android:text="@string/main_MediaPlayer"
app:layout_constraintBottom_toTopOf="@+id/ID_SpectrumView_Button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/ID_SpectrumView_Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="48dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="16dp"
android:text="@string/main_SpectrumView"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.25"
app:layout_constraintStart_toStartOf="parent" />
</android.support.constraint.ConstraintLayout>
代码都不起作用,我不知道为什么 (layout.setBackgroundResource(R.drawable.background),图像视图和比例 fitXY 都不起作用......这太荒谬了
【问题讨论】:
标签: android xml android-layout background