I'm facing error in using this view
Code is as following:
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/circleImageView"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
i tried checking dependencies, it didn't work
What is the error?
I simply add
implementation 'de.hdodenhof:circleimageview:3.1.0'
to the apps build.gradle dependencies and copied your code in the xml and it worked.
Related
I wanted to create a new Android launch screen for my Flutter app using constraint layout.
Firstly, I wasn't able to directly open layout builder in Android Studio in my Flutter app project. So using Android Studio, I created a new Android app with an empty activity and used the layout builder to create my layout by setting constraints. I then copied the generated XML into launch_background.xml of my Flutter project - where my previous splashscreen (not using constraint layout) had been working. I added this vectorDrawables.useSupportLibrary = true in the android.defaultConfig in and compile 'com.android.support:appcompat-v7:24.1.1' in dependencies, both in build.gradle.
I'm now unable to run my app because of errors for each constraint:
attribute layout_constraintTop_toTopOf (aka pha.myapp.dep.us:layout_constraintTop_toTopOf) not found.
...and repeat for each constraint.
How have I already tried to fix it?
I tried with this: implementation 'androidx.constraintlayout:constraintlayout:2.0.4' in the
dependencies in build.gradle but my app was stuck building for over
an hour.
I've run flutter clean
I've deleted my entire gradle file.
Am I missing something?
Finally, as reference, this is my XML file. The three drawables exist and have worked before when I haven't used constraint layout.
<?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"
>
<ImageView
android:id="#+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
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.0"
app:srcCompat="#drawable/ic_bg_splash" />
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="157dp"
android:layout_marginLeft="157dp"
android:layout_marginEnd="157dp"
android:layout_marginRight="157dp"
android:layout_marginBottom="32dp"
app:layout_constraintBottom_toBottomOf="#+id/imageView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0"
app:srcCompat="#drawable/ic_logo" />
<ImageView
android:id="#+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="56dp"
android:layout_marginLeft="56dp"
android:layout_marginEnd="56dp"
android:layout_marginRight="56dp"
android:layout_marginBottom="20dp"
app:layout_constraintBottom_toBottomOf="#+id/imageView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/imageView"
app:srcCompat="#drawable/ic_brandlogotag" />
</androidx.constraintlayout.widget.ConstraintLayout>
I'm Using circulcar image view libary available on github. I also add it to build.gradle and sync it. but i am still not getting circular image. if I add SRC insted of background, still not getting result. where i am wrong?
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/imageView"
android:layout_width="200dp"
android:layout_height="200dp"
android:background="#drawable/splash_screen"
app:civ_border_width="10dp"
app:civ_border_color="#FF000000"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView" />
remove this line : android:background="#drawable/splash_screen"
and Add this line : android:src="#drawable/splash_screen"
Just change the background line. It will show the circular image.
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/imageView"
android:layout_width="200dp"
android:src="#drawable/splash_screen"
android:layout_height="200dp"
app:civ_border_width="10dp"
app:civ_border_color="#FF000000"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView" />
Image was displayed to the background that's why it was showing the square.
I created a fragment_b.xml file in my resources/layout folder. On my two buttons I get the following warning:
Element Button is not allowed here
Why is this warning popping up? My code is working fine.
fragment_b.xml:
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<Button
android:id="#+id/btn_fragment_b"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/go_to_fragment_c"
app:layout_constraintBottom_toTopOf="#id/btn_nagivate_to_fragment_f"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<Button
android:id="#+id/btn_nagivate_to_fragment_f"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/go_to_fragment_f"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/btn_fragment_b"
android:layout_marginTop="#dimen/a_lot_of_margin"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
This will happen if you don't have the androidx ConstraintLayout library added as a dependency in your gradle files.
In your app/build.gradle file, in the dependencies block, add this:
dependencies {
// ...
implementation "androidx.constraintlayout:constraintlayout:2.0.0-beta3"
}
Of course you can use a different library version, but the androidx.constraintlayout:constraintlayout: part is important.
Once that's done, do a gradle sync and rebuild your project and the warning should go away.
Try change it to:
androidx.appcompat.widget.AppCompatButton
or
com.google.android.material.button.MaterialButton
I'm just trying to use the group view with the android constraint layout to set the visibility of several views more easily. Problem is even though I change the visibility of a group to gone or invisible it does not do anything.
I'v already tried the steps of Pavan's response in this thread: toggle visibility of chain group in constraint layout.
But it didn't change anything for me. (I assume it's because I'm not using the beta version)
Here is my dependencies app gradle file
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
This is an extract of my XML file with the group
<Button
android:text="#string/action_update"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/button_update"
android:layout_marginBottom="32dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp" android:layout_marginRight="8dp"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp" app:layout_constraintStart_toStartOf="parent" android:textSize="18sp"/>
<android.support.constraint.Group android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="#+id/group"
android:visibility="gone"
app:constraint_referenced_ids="button_update"/>
You are importing the Group widget from a wrong package.
Change
<android.support.constraint.Group
To
<androidx.constraintlayout.widget.Group
Updated Version
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
..............................................
>
<Button
android:id="#+id/button_update"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="32dp"
android:text="#string/action_update"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<androidx.constraintlayout.widget.Group
android:id="#+id/group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
app:constraint_referenced_ids="button_update" />
</androidx.constraintlayout.widget.ConstraintLayout>
The thing is I didn't notice that when I created my android studio project, i didn't check the box "Use androidx artifacts" which automatically makes your project use the new androidx library. Androidx tends to replace the support library (See more details here: https://developer.android.com/jetpack/androidx)
So basically, I followed the steps given here to convert my project to androidx and now everything is working perfectly.
Thank for your time #theapache64, now your code is working.
As shown in the image, the constraints are not visible besides activating them.
I have no idea how to solve this problem.
Thanks.
[Edit]
Here is the XML Code, i haven't changed anything just added the Elements on the Design Tab.
<?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:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="81dp">
<Button
android:id="#+id/btn_jump"
android:layout_width="128dp"
android:layout_height="48dp"
android:text="Jump Activity"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:layout_constraintBottom_creator="1"
tools:layout_constraintLeft_creator="1"
tools:layout_constraintRight_creator="1"
tools:layout_constraintTop_creator="1" />
<EditText
android:id="#+id/edt_Name"
android:layout_width="215dp"
android:layout_height="43dp"
android:layout_marginTop="107dp"
android:ems="10"
android:inputType="textPersonName"
android:text=""
app:layout_constraintHorizontal_bias="0.502"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:layout_constraintLeft_creator="1"
tools:layout_constraintRight_creator="1"
tools:layout_constraintTop_creator="1" />
</android.support.constraint.ConstraintLayout>
It is happen In Android Studio 3.1.3 when We are using appcompact-v7:28.0.0-alpha3 library (It automatically take this library). Open the build.gradle (Module:app) and check in the dependencies that which version of appcompact are you using. If "com.android.support:appcompat-v7:28.0.0-alpha3" then just changed the alpha3 to alpha1 or you can use the previous version 27 also. Now you can see it all component in the blueprint.
Well this is a known issue in appCompat library version v7-28.0.0alpha/ which is being used directly with the latest build tools!
there are two solutions to this!
either upgrade your build tools from your sdk manager's tools tab!
or second way
is reverting back to 27.1.1
change the highlighted one into as
My version version of Android Studio (v3.1.4) has a slightly different line of code for appcompact with no mention of alpha3
implementation 'com.android.support:appcompact-v7:28.0.0-rc01' so i just changed it to
above version 27 and clicked Sync Project With Gradle Files and it now shows the constraints perfectly.