Home > Blockchain >  xml won't build, how other possible way
xml won't build, how other possible way

Time:02-11

I could not build my project due to this xml code, but cannot figure out where exactly lays the problem. I first used scrollView, I did delete it, and used ListView instead. Since then could not run my project. the error I am getting is this:

here is the code

<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:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:anddroid="http://schemas.android.com/apk/res/android"
    android:background="#FFFCEC">


    <com.google.android.material.tabs.TabLayout
        android:id="@ id/tab_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#0BA811"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="1.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.0" />

    <androidx.viewpager2.widget.ViewPager2
        android:id="@ id/pager"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_marginBottom="48dp"
        android:layout_weight="1"
        android:orientation="vertical"
        android:layoutDirection="rtl"
        app:layout_constraintBottom_toBottomOf="@ id/tab_layout" />

    <TextView
        android:id="@ id/textView2"
        android:layout_width="310dp"
        android:layout_height="49dp"
        android:text="Here where your friends are!"
        android:textColor="#127A00"
        android:textSize="24sp"
        android:textStyle="italic"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.495"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.832" />

    <TextView
        android:id="@ id/textView4"
        android:layout_width="270dp"
        android:layout_height="88dp"
        android:text="theFinder"
        android:textColor="#127A00"
        android:textSize="60sp"
        android:textStyle="bold|italic"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.496"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.729" />

    <Button
        android:id="@ id/btnscan"
        android:layout_width="408dp"
        android:layout_height="75dp"
        android:backgroundTint="#127A00"
        android:text="press to Scan"
        android:textColor="#EDFFFFFF"
        android:textColorHighlight="#FFFFFFFF"
        android:textSize="20sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.996" />

    <ProgressBar
        android:id="@ id/pBar"
        style="@android:style/Widget.ProgressBar.Large"
        android:layout_width="113dp"
        android:layout_height="77dp"
        android:indeterminate="true"
        android:indeterminateOnly="true"
        android:max="100"
        android:progress="10"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.578" />

    <TextView
        android:id="@ id/tView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text=""
        android:textColor="#1E7822"
        android:textSize="16sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.498"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.566" />

    <ListView
        android:id="@ id/lst_view"
        anddroid:layout_width="409dp"
        android:layout_width="396dp"
        anddroid:layout_height="328dp"
        android:layout_height="244dp"
        android:background="#D80E1127"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.141" />``` 

CodePudding user response:

Your root element specifies two aliases for the same namespace:

  • xmlns:android="http://schemas.android.com/apk/res/android"
  • xmlns:anddroid="http://schemas.android.com/apk/res/android"

Then in the ListView with an ID of @ id/lst_view you specify layout_height and layout_width twice, once with each alias:

        anddroid:layout_width="409dp"
        android:layout_width="396dp"
        anddroid:layout_height="328dp"
        android:layout_height="244dp"

That means you're specifying the same namespace-qualified attribute twice for each of width and height. That's not allowed.

Just remove the anddroid typo-alias, and remove the two attributes using it.

  • Related