I'm trying to build a simple android app in Android Studio 2.3.2, but I'm getting the following error for component I add to the app: "No resource identifier found for attribute 'layout_constraintBottom' in package 'com..."
I researched this problem and found that some people are getting a similar error. However, the answers are suggesting to add "compile 'com.android.support.constraint:constraint-layout:1.0.2'" to the gradle.build file. When I looked there, the line is already in place.
Here is a snippet of my code:
<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"
android:background="#drawable/main_menu"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.example.nmeneses.scorekeeper.MainMenu"
tools:showIn="#layout/activity_main_menu">
<Button
android:id="#+id/button3"
android:layout_width="128dp"
android:layout_height="79dp"
android:layout_marginBottom="50dp"
android:layout_marginLeft="39dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:text="Teams"
android:textSize="23dp"
app:layout_constraintBottom="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.066"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0" />
Any help would be greatly appreciated. If you need more info, please let me know.
AFAIK there is no attribute layout_constraintBottom in ConstraintLayout. There is layout_constraintBottom_toTopOf and layout_constraintBottom_toBottomOf.
I suggest that you use the following line instead:
app:layout_constraintBottom_toBottomOf="parent"
Related
After install of android studio I wanted to create a test app so I added only one button to the default hello world app and run it but I got this error. (after search stackoverflow for similar problem and solution I ask a question......)
AAPT: error: '???dp' is incompatible with attribute layout_marginEnd (attr) dimension.
here is auto generated code by android studio:
<?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/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hello world!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="۳۲dp"
android:layout_marginEnd="۱۸۰dp"
android:text="Button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView" />
</androidx.constraintlayout.widget.ConstraintLayout>
Numbers written in a non-English language will probably be corrected by change
android:layout_marginTop="32dp"
android:layout_marginEnd="180dp"
You have used arabic numerals for android:layout_marginTop="۳۲dp" && android:layout_marginEnd="۱۸۰dp" use english numbering instead like "10dp"
Change this:
android:layout_marginTop="۳۲dp"
android:layout_marginEnd="۱۸۰dp"
to:
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
(inside the Button tag)
I am new to Android Studio. I started building an app. This is the code of my xml file. I can't figure out the problem! This is the exact error code that I am getting."ParseError at [row,col]:[60,1]
Message: XML document structures must start and end within the same entity."
<?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"
android:background="#121212"
tools:context=".MainActivity"
>
<ImageView
android:id="#+id/imageView"
android:layout_width="844dp"
android:layout_height="1090dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.501"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.988"
app:srcCompat="#drawable/up_notch_adobespark" />
<ImageButton
android:id="#+id/imageButton4"
android:layout_width="50dp"
android:layout_height="54dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.005"
tools:srcCompat="#drawable/more_button" />
<ImageButton
android:id="#+id/imageButton7"
android:layout_width="59dp"
android:layout_height="66dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.997"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.004"
app:srcCompat="#drawable/help_icon" />
<TextView
android:id="#+id/textView"
android:layout_width="165dp"
android:layout_height="36dp"
android:fontFamily="#font/baloo_tamma"
android:text="Hi Josh."
android:textSize="22dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.065"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.158" />
just like broot explained … XML syntax is similar to HTML it has an opening and closing tag, so you need to close every single tag you open in which your case is the constraint layout . just add this line to the end of your xml file
</androidx.constraintlayout.widget.ConstraintLayout>
another advice would be very useful is to avoid using horizontal and vertical bias, I believe that padding(s) and margins(s) are more than enough to help you design the layout you want
and try also using for width and height wrap_content or match parent for detailed and correct measurement for the most phones that will be used. because if you changed the amuleter you are using you will notice that the measurement will be diffrient so as a best practice is to use wrap_content or match parent
Error message is pretty self-explanatory. You opened ConstraintLayout tag at the beginning of the document, but you never closed it. You need to add the following at the end:
</androidx.constraintlayout.widget.ConstraintLayout>
I'm getting a build error: 'failed linking file resources' in Android Studio. How do I solve this?
This is the problem:
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_marginBottom="75dp"
android:gravity="center"
android:textSize="400sp"
android:removeView=""
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent" />
android:removeView doesn't exist. Remove that line.
there is some thing wrong in one of the XML files
you can go back and check your recently added/changed XML
for me it was spelling mistake(vible instead of visible)
<ProgressBar
android:id="#+id/prog_bar"
style="#style/ProgressBar.Green"
android:layout_width="0dp"
android:layout_height="20dp"
android:layout_weight="1"
**android:visibility="vible"**/>
This question already has answers here:
Android Studio does not show layout preview
(34 answers)
Closed 4 years ago.
I just started with the Build your first app tutorial from android.com but for some reason, the design view does not show anything I drag or drop to it. I've tried creating buttons, text, plaintext etc, all with no errors, however, I can only see it when I run the app. What am I missing?
Running Android studio 3.1.4 on Ubuntu 18.04.1 LTS.
This is my first time using it, and I searched for similar questions before posting and only found questions/answers that were not similar enough to my issue to be helpful. I have tried rebuilding and invalidating the cache/restart with no avail.
Here are some snaps:
Snap of studio
Snap of emulator
Last here is the activity_main.xml:
<?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:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="#+id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/activity_horizontal_margin"
android:layout_marginStart="#dimen/activity_horizontal_margin"
android:layout_marginTop="#dimen/activity_vertical_margin"
android:text="#string/title_home"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<android.support.design.widget.BottomNavigationView
android:id="#+id/navigation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="0dp"
android:layout_marginStart="0dp"
android:background="?android:attr/windowBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="#menu/navigation" />
<EditText
android:id="#+id/editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="KoDy Abbott"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
Please let me know if you need anything else to help answer my question. Thank you in advanced, hopefully it is something simple that I am overlooking but at this point its easier for me to ask then bang my head for another few hours.....
There is no error in your project but there are some bugs in the recent update of support libraries
Change support libraries version to 28.0.0-alpha1 and it will work all
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support:design:28.0.0-alpha1'
Other solutions is that you can find an image button on the up-left. Click it and you can find a option called "force to refresh layout", click it and you problem will be solved.
I'm trying to centre two textviews vertically using constraint layout chains. I know I can wrap the text layouts in a linear layout but I wanted to try out the new chain feature. When I build my project though I get an error, Error:(28, 50) No resource found that matches the given name (at 'layout_constraintBottom_toTopOf' with value '#id/item_school_location').
<?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">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="72dp">
<ImageView
android:id="#+id/item_school_logo"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginStart="16dp"
android:contentDescription="#string/item_school_logo_description"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.5" />
<TextView
android:id="#+id/item_school_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="72dp"
android:maxLines="1"
android:textAppearance="#style/TextAppearance.AppCompat.Light.SearchResult.Subtitle"
app:layout_constraintBottom_toTopOf="#id/item_school_location"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.5"
app:layout_constraintVertical_chainPacked="true" />
<TextView
android:id="#+id/item_school_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="72dp"
android:maxLines="1"
android:textAppearance="#style/TextAppearance.AppCompat.Small"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="#id/item_school_name" />
</android.support.constraint.ConstraintLayout>
</layout>
Anyone know what's causing this error?
app:layout_constraintLeft_toLeftOf="parent"
Maybe I'm not completely up to date, but I think the value shouldn't be "parent" - it should be a view ID (in the format of "#+id/some_id").
Give your constraint layout an id and then try using that instead of parent.
Edit: I guess I am out of date on this? Because I just read that again, and your error seems like this line:
layout_constraintBottom_toTopOf="#id/item_school_location"
is missing the + after # - as in it should be
layout_constraintBottom_toTopOf="#+id/item_school_location"
I think the
No resource found that matches the given name
error is due to the fact that you are referencing the id of an element (item_school_location) that is declared after the element referencing it (item_school_name).
In this case, it would help if you declare the ids of your related elements in a separate ids.xml file (check this: https://stackoverflow.com/a/12247971)