android.view.InflateException:二进制XML文件第11行:膨胀类ImageView的错误

时间:2019-07-19 14:31:52

标签: java android

我只是tryna制作了一个小小的android java xml应用程序,该应用程序计算了游戏的得分,它给了我这个错误“错误使ImageView膨胀” ..有人知道解决方案吗?

我实际上进行了搜索,ppl说添加了它:android:contentDescription =“ @ string / app_name” 它实际上什么也没做

XML:

Sub tryKeywordsearch()

Dim http As Object, html As New HTMLDocument
Dim paras As Object, titleElem As Object, detailsElem As Object, para As HTMLHtmlElement
Dim i As Integer
Set http = CreateObject("MSXML2.XMLHTTP")
http.Open "GET", "https://www.fool.com/earnings/call-transcripts/2019/07/17/netflix-inc-nflx-q2-2019-earnings-call-transcript.aspx", False
http.Send
html.body.innerHTML = http.responseText

Set paras = html.getElementsByClassName("article-content")

i = 1

For Each para In paras
    Set para = para.getElementsByTagName("p")(i)
    Sheets(1).Cells(i, 1).Value = para.innerText
    i = i + 1
Next
End sub

JAVA:

    <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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:id="@+id/linearLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">


    <ImageView
        android:id="@+id/imageView3"
        android:layout_width="417dp"
        android:layout_height="732dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:contentDescription="@string/app_name"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/lebronjames" />

    <TextView
        android:id="@+id/teamAScore3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="44dp"
        android:text="0"
        android:textColor="@android:color/background_light"
        android:textSize="60sp"
        app:layout_constraintEnd_toEndOf="@+id/teamA"
        app:layout_constraintStart_toStartOf="@+id/teamA"
        app:layout_constraintTop_toBottomOf="@+id/teamA" />

    <View
        android:id="@+id/divider"
        android:layout_width="3dp"
        android:layout_height="480dp"
        android:layout_marginStart="8dp"
        android:layout_marginBottom="8dp"
        android:background="#FF9800"
        app:layout_constraintBottom_toBottomOf="@+id/imageView3"
        app:layout_constraintEnd_toEndOf="@+id/imageView3"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@+id/imageView3"
        app:layout_constraintVertical_bias="0.098" />

    <TextView
        android:id="@+id/teamA"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginTop="24dp"
        android:layout_marginEnd="8dp"
        android:text="Team A"
        android:textColor="@android:color/background_light"
        android:textSize="25sp"
        app:layout_constraintEnd_toStartOf="@+id/divider"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/teamB"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp"
        android:text="Team B"
        android:textColor="@android:color/background_light"
        android:textSize="25sp"
        app:layout_constraintBottom_toBottomOf="@+id/teamA"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.339"
        app:layout_constraintStart_toEndOf="@+id/divider"
        app:layout_constraintTop_toTopOf="@+id/teamA" />

    <TextView
        android:id="@+id/teamBScore"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="0"
        android:textColor="@android:color/background_light"
        android:textSize="60sp"
        app:layout_constraintBottom_toBottomOf="@+id/teamAScore3"
        app:layout_constraintEnd_toEndOf="@+id/teamB"
        app:layout_constraintStart_toStartOf="@+id/teamB"
        app:layout_constraintTop_toTopOf="@+id/teamAScore3" />

    <Button
        android:id="@+id/points2ButtonB"
        android:layout_width="156dp"
        android:layout_height="68dp"
        android:layout_marginEnd="8dp"
        android:text="+2 points"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.882"
        app:layout_constraintStart_toEndOf="@+id/points2ButtonA"
        app:layout_constraintTop_toTopOf="@+id/points2ButtonA" />

    <Button
        android:id="@+id/points2ButtonA"
        android:layout_width="156dp"
        android:layout_height="68dp"
        android:layout_marginTop="28dp"
        android:text="+2 points"
        android:onClick="twoPointerA"
        app:layout_constraintEnd_toEndOf="@+id/teamAScore3"
        app:layout_constraintStart_toStartOf="@+id/teamAScore3"
        app:layout_constraintTop_toBottomOf="@+id/teamAScore3" />

    <Button
        android:id="@+id/freeShotButtonA"
        android:layout_width="156dp"
        android:layout_height="68dp"
        android:layout_marginTop="36dp"
        android:text="Free shot"
        app:layout_constraintStart_toStartOf="@+id/point3ButtonA"
        app:layout_constraintTop_toBottomOf="@+id/point3ButtonA" />

    <Button
        android:id="@+id/freeShotButtonB"
        android:layout_width="156dp"
        android:layout_height="68dp"
        android:text="Free shot"
        app:layout_constraintStart_toStartOf="@+id/point3ButtonB"
        app:layout_constraintTop_toTopOf="@+id/freeShotButtonA" />

    <Button
        android:id="@+id/point3ButtonB"
        android:layout_width="156dp"
        android:layout_height="68dp"
        android:layout_marginEnd="8dp"
        android:text="+3 points"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.882"
        app:layout_constraintStart_toEndOf="@+id/point3ButtonA"
        app:layout_constraintTop_toTopOf="@+id/point3ButtonA" />

    <Button
        android:id="@+id/point3ButtonA"
        android:layout_width="156dp"
        android:layout_height="68dp"
        android:layout_marginTop="24dp"
        android:text="+3 points"
        app:layout_constraintStart_toStartOf="@+id/points2ButtonA"
        app:layout_constraintTop_toBottomOf="@+id/points2ButtonA" />

    <Button
        android:id="@+id/resetButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginTop="160dp"
        android:layout_marginEnd="8dp"
        android:text="reset"
        android:textColorHint="@android:color/holo_orange_dark"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.498"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/divider" />

</androidx.constraintlayout.widget.ConstraintLayout>
  

java.lang.RuntimeException:无法启动活动   ComponentInfo {com.example.basketballscore / com.example.basketballscore.MainActivity}:   android.view.InflateException:二进制XML文件第11行:二进制XML   文件行#11:膨胀类ImageView时出错

2 个答案:

答案 0 :(得分:1)

android:src

  

设置一个可绘制对象作为此ImageView的内容,它将显示在   它的原始大小。没有自动缩放。

删除行

app:srcCompat="@drawable/lebronjames"

并使用

进行更改
android:src="@drawable/lebronjames"

并将图像放置在 Drawable 文件夹而不是 Drawable-v24

请阅读此Answer,您将获得解决方案

答案 1 :(得分:0)

此错误是由于您使用app:srcCompat="@drawable/lebronjames",仅将srcCompat属性更改为src或将ImageView更改为appCompatImageView而在您的xml代码的最后一行引起的