0

I am new to Android Studio and am currently working on creating my first app. Unfortunately, I am encountering an issue that I am struggling to resolve.P.S"First time asking in Stack"

this is the Layout file. the error that i mostly get is related to the textview the errors i mostly got from was: android:gravity="center_horizontal android:textColor="#4BB6E8"

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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=".hamstringActivity1">

    <ImageView
        android:id="@+id/menubtn"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:src="@drawable/menubtn"
        android:padding="15dp"/>

    <ImageView
        android:id="@+id/notesbtn"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:layout_alignParentEnd="true"
        android:layout_marginStart="360dp"
        android:layout_marginTop="0dp"
        android:layout_marginEnd="-19dp"
        android:padding="15dp"
        android:src="@drawable/nots"/>

    <TextView
        android:id="@+id/deadtext"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:layout_alignParentEnd="true"
        android:layout_marginTop="47dp"
        android:layout_marginEnd="-2dp"
        android:gravity="center"
        android:text="barbell_deadlifts"
        android:textColor="#4BB6E8"
        android:textSize="20sp"
        android:textStyle="bold"
        />

    <LinearLayout
        android:id="@+id/lay5"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_below="@+id/deadtext"
        android:layout_alignParentStart="true"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginStart="0dp"
        android:layout_marginTop="0dp"
        android:layout_marginBottom="480dp"
        android:orientation="horizontal">

        <VideoView
            android:id="@+id/hami1"
            android:layout_width="match_parent"
            android:layout_height="180dp"
            android:alpha="1.2"
            android:background="?attr/selectableItemBackgroundBorderless"
            android:elevation="10dp"
            android:scaleType="fitXY"
            android:src="@raw/hami1">
        </VideoView>
    </LinearLayout>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:layout_marginTop="264dp"
        android:text="TARGETED MUSCLE GROUPS"
        android:textColor="#4BB6E8"
        android:textStyle="bold"
        android:textSize="15sp"/>
<!--        android:gravity="center_horizontal"/>-->

    <LinearLayout
        android:layout_width="412dp"
        android:layout_height="178dp"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentBottom="true"
        android:layout_centerInParent="true"
        android:layout_marginStart="7dp"
        android:layout_marginTop="282dp"
        android:layout_marginEnd="-6dp"
        android:layout_marginBottom="270dp"
        android:orientation="horizontal">

        <ImageView
            android:layout_width="200dp"
            android:layout_height="180dp"
            android:background="?attr/selectableItemBackgroundBorderless"
            android:elevation="10dp"
            android:padding="2dp"
            android:scaleType="fitXY"
            android:src="@drawable/hami2">

        </ImageView>

        <ImageView
            android:layout_width="200dp"
            android:layout_height="180dp"
            android:alpha="1.2"
            android:background="?attr/selectableItemBackgroundBorderless"
            android:elevation="10dp"
            android:padding="2dp"
            android:scaleType="fitXY"
            android:src="@drawable/card2">

        </ImageView>


    </LinearLayout>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="245dp"
        android:text="INSTRUCTIONS"
        android:textSize="15sp"
        android:textStyle="bold"
        android:textColor="#4BB6E8"/>
<!--        android:gravity="center_horizontal"-->


    <HorizontalScrollView
        android:layout_width="match_parent"
        android:layout_height="244dp"
        android:layout_alignParentStart="true"
        android:layout_alignParentBottom="true"
        android:layout_marginStart="0dp"
        android:layout_marginBottom="1dp">

        <LinearLayout
            android:layout_width="100dp"
            android:layout_height="200dp">

            <ScrollView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">

                <TextView
                    android:id="@+id/inst1"
                    android:layout_width="200dp"
                    android:layout_height="243dp"
                    android:lineSpacingExtra="3sp"
                    android:padding="5dp"
                    android:text="@string/hami1"
                    android:textColor="#4BB6E8"/>


            </ScrollView>

            <EditText
                android:layout_width="200dp"
                android:layout_height="243dp"
                android:hint="Write notes here..."
                android:textColorHint="#4BB6E8"
                android:gravity="center_horizontal"
                android:padding="5sp"/>


        </LinearLayout>


    </HorizontalScrollView>

The error i got from Logcat.

2023-03-13 21:27:40.492 4403-4403/com.example.projectmpa E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.projectmpa, PID: 4403
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.projectmpa/com.example.projectmpa.hamstringActivty}: android.view.InflateException: Binary XML file line #43 in com.example.projectmpa:layout/activity_hamstring: Binary XML file line #43 in com.example.projectmpa:layout/activity_hamstring: Error inflating class TextView
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3449)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
     Caused by: android.view.InflateException: Binary XML file line #43 in com.example.projectmpa:layout/activity_hamstring: Binary XML file line #43 in com.example.projectmpa:layout/activity_hamstring: Error inflating class TextView
     Caused by: android.view.InflateException: Binary XML file line #43 in com.example.projectmpa:layout/activity_hamstring: Error inflating class TextView

Here is what i tried: Typos or syntax errors in the XML code:

  • did you post a full XML? I don't see the closing of the at the end of the file – Mikhail Mar 14 '23 at 03:36
  • Yes i did "" its the only missing part for some reason stack was not letting me pasting the entire XML code – Ziad Suliman Mar 14 '23 at 12:01
  • Judging by the log not seems to be related, but VideoView doesn't have an attribute `android:src`, can you try to remove it just in case? – Mikhail Mar 15 '23 at 02:07

0 Answers0