Issue
When I put "app:" in main_activity.xml, doesn't work the autocompletion, it only shows 1 option:
appNs
But when I do in another xml like fragment_owl.xml, it gives me all the attributes of app namespace. I have xmlns:app="http://schemas.android.com/apk/res-auto in both of them
this are my xmls
activity_main.xml: (that has autocompletion of app namespace attributes)
<?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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@+id/holamundo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="69dp"
android:text="Hola Mundo"
android:textAllCaps="false"
android:textSize="36sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/roll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="134dp"
android:text="GIRAR"
android:textSize="36sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<ImageView
android:id="@+id/dice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/empty_dice"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat = "@drawable/dice_1"
/>
<!-- android:src="@drawable/dice_1"-->
</androidx.constraintlayout.widget.ConstraintLayout>
but in this another one:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<fragment
android:id="@+id/navHostFragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:navGraph="@navigation/navigation"
app:defaultNavHost="true"
app <- NO AUTOCOMPLETION :(
/>
</LinearLayout>
</layout>
I've already try invalite cache and delete or override some folders but nothings seems to work for me.
Solution
After doing some digging i found out the following
Changing your LinearLayout
to a ConstraintLayout
solves your problem, but why?
ConstraintLayout
is from a library (you import it via your build.gradle androidx.constraintlayout:constraintlayout:*.*.*
)
CommonsWare explains it here android.support.constraint is from a library, not the platform.
Taking this into account Android Studio maybe doesnt understand the app
namespace for layouts that belong to the Android platform like LinearLayout
as they are part of the android
namespace.
This is my interpretation, hope it answers your question
Answered By - Jaime
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.