Make square image in Glide and then round it
I solve a typical task for image: try to centerCrop()
it and make circular like in How to round an image with Glide library?, but a result seems like Glide circular image gets cropped or
(not circular).
I think Glide (v.4) doesn't correctly crop the image. I tried many variants like GlideApp.with(photo).load(url).circleCrop().into(photo)
. Probably better would be first to create a square from a rectangle and then make it circular.
This is a part of 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:layout_width="match_parent"
android:layout_height="wrap_content"
>
<ImageView
android:id="@+id/photo"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginStart="15dp"
android:layout_marginLeft="15dp"
android:layout_marginTop="20dp"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@drawable/image_1"
/>
<TextView
android:id="@+id/name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="7dp"
android:layout_marginLeft="7dp"
android:lineSpacingExtra="1sp"
android:textColor="@color/black"
android:textSize="20sp"
app:layout_constraintEnd_toStartOf="parent"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintStart_toEndOf="@+id/photo"
app:layout_constraintTop_toTopOf="@+id/photo"
tools:text="Name"
/>
</android.support.constraint.ConstraintLayout>
UPDATE
Sorry, a problem was in a source image. I didn't think it was this (lines are added):
android android-glide
add a comment |
I solve a typical task for image: try to centerCrop()
it and make circular like in How to round an image with Glide library?, but a result seems like Glide circular image gets cropped or
(not circular).
I think Glide (v.4) doesn't correctly crop the image. I tried many variants like GlideApp.with(photo).load(url).circleCrop().into(photo)
. Probably better would be first to create a square from a rectangle and then make it circular.
This is a part of 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:layout_width="match_parent"
android:layout_height="wrap_content"
>
<ImageView
android:id="@+id/photo"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginStart="15dp"
android:layout_marginLeft="15dp"
android:layout_marginTop="20dp"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@drawable/image_1"
/>
<TextView
android:id="@+id/name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="7dp"
android:layout_marginLeft="7dp"
android:lineSpacingExtra="1sp"
android:textColor="@color/black"
android:textSize="20sp"
app:layout_constraintEnd_toStartOf="parent"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintStart_toEndOf="@+id/photo"
app:layout_constraintTop_toTopOf="@+id/photo"
tools:text="Name"
/>
</android.support.constraint.ConstraintLayout>
UPDATE
Sorry, a problem was in a source image. I didn't think it was this (lines are added):
android android-glide
Better to useCircleImageView
. It's easy and effective.
– Rumit Patel
Nov 14 '18 at 13:12
@RumitPatel, yes, but if I have Glide, probably it can handle cropping.
– CoolMind
Nov 14 '18 at 13:38
1
yes @CoolMind , you wrote you have tried and Glide (v.4) doesn't correctly crop the image. so I suggested alternate and better way. I had same issue and I preferred to useCircleImageView.
:-)
– Rumit Patel
Nov 14 '18 at 13:47
@RumitPatel, thanks. Strange that you have a namesake here. :)
– CoolMind
Nov 14 '18 at 13:54
@RumitPatel, sorry, I updated the question.
– CoolMind
Nov 14 '18 at 15:41
add a comment |
I solve a typical task for image: try to centerCrop()
it and make circular like in How to round an image with Glide library?, but a result seems like Glide circular image gets cropped or
(not circular).
I think Glide (v.4) doesn't correctly crop the image. I tried many variants like GlideApp.with(photo).load(url).circleCrop().into(photo)
. Probably better would be first to create a square from a rectangle and then make it circular.
This is a part of 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:layout_width="match_parent"
android:layout_height="wrap_content"
>
<ImageView
android:id="@+id/photo"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginStart="15dp"
android:layout_marginLeft="15dp"
android:layout_marginTop="20dp"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@drawable/image_1"
/>
<TextView
android:id="@+id/name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="7dp"
android:layout_marginLeft="7dp"
android:lineSpacingExtra="1sp"
android:textColor="@color/black"
android:textSize="20sp"
app:layout_constraintEnd_toStartOf="parent"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintStart_toEndOf="@+id/photo"
app:layout_constraintTop_toTopOf="@+id/photo"
tools:text="Name"
/>
</android.support.constraint.ConstraintLayout>
UPDATE
Sorry, a problem was in a source image. I didn't think it was this (lines are added):
android android-glide
I solve a typical task for image: try to centerCrop()
it and make circular like in How to round an image with Glide library?, but a result seems like Glide circular image gets cropped or
(not circular).
I think Glide (v.4) doesn't correctly crop the image. I tried many variants like GlideApp.with(photo).load(url).circleCrop().into(photo)
. Probably better would be first to create a square from a rectangle and then make it circular.
This is a part of 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:layout_width="match_parent"
android:layout_height="wrap_content"
>
<ImageView
android:id="@+id/photo"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginStart="15dp"
android:layout_marginLeft="15dp"
android:layout_marginTop="20dp"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@drawable/image_1"
/>
<TextView
android:id="@+id/name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="7dp"
android:layout_marginLeft="7dp"
android:lineSpacingExtra="1sp"
android:textColor="@color/black"
android:textSize="20sp"
app:layout_constraintEnd_toStartOf="parent"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintStart_toEndOf="@+id/photo"
app:layout_constraintTop_toTopOf="@+id/photo"
tools:text="Name"
/>
</android.support.constraint.ConstraintLayout>
UPDATE
Sorry, a problem was in a source image. I didn't think it was this (lines are added):
android android-glide
android android-glide
edited Nov 14 '18 at 15:37
CoolMind
asked Nov 14 '18 at 13:01
CoolMindCoolMind
3,85713471
3,85713471
Better to useCircleImageView
. It's easy and effective.
– Rumit Patel
Nov 14 '18 at 13:12
@RumitPatel, yes, but if I have Glide, probably it can handle cropping.
– CoolMind
Nov 14 '18 at 13:38
1
yes @CoolMind , you wrote you have tried and Glide (v.4) doesn't correctly crop the image. so I suggested alternate and better way. I had same issue and I preferred to useCircleImageView.
:-)
– Rumit Patel
Nov 14 '18 at 13:47
@RumitPatel, thanks. Strange that you have a namesake here. :)
– CoolMind
Nov 14 '18 at 13:54
@RumitPatel, sorry, I updated the question.
– CoolMind
Nov 14 '18 at 15:41
add a comment |
Better to useCircleImageView
. It's easy and effective.
– Rumit Patel
Nov 14 '18 at 13:12
@RumitPatel, yes, but if I have Glide, probably it can handle cropping.
– CoolMind
Nov 14 '18 at 13:38
1
yes @CoolMind , you wrote you have tried and Glide (v.4) doesn't correctly crop the image. so I suggested alternate and better way. I had same issue and I preferred to useCircleImageView.
:-)
– Rumit Patel
Nov 14 '18 at 13:47
@RumitPatel, thanks. Strange that you have a namesake here. :)
– CoolMind
Nov 14 '18 at 13:54
@RumitPatel, sorry, I updated the question.
– CoolMind
Nov 14 '18 at 15:41
Better to use
CircleImageView
. It's easy and effective.– Rumit Patel
Nov 14 '18 at 13:12
Better to use
CircleImageView
. It's easy and effective.– Rumit Patel
Nov 14 '18 at 13:12
@RumitPatel, yes, but if I have Glide, probably it can handle cropping.
– CoolMind
Nov 14 '18 at 13:38
@RumitPatel, yes, but if I have Glide, probably it can handle cropping.
– CoolMind
Nov 14 '18 at 13:38
1
1
yes @CoolMind , you wrote you have tried and Glide (v.4) doesn't correctly crop the image. so I suggested alternate and better way. I had same issue and I preferred to use
CircleImageView.
:-)– Rumit Patel
Nov 14 '18 at 13:47
yes @CoolMind , you wrote you have tried and Glide (v.4) doesn't correctly crop the image. so I suggested alternate and better way. I had same issue and I preferred to use
CircleImageView.
:-)– Rumit Patel
Nov 14 '18 at 13:47
@RumitPatel, thanks. Strange that you have a namesake here. :)
– CoolMind
Nov 14 '18 at 13:54
@RumitPatel, thanks. Strange that you have a namesake here. :)
– CoolMind
Nov 14 '18 at 13:54
@RumitPatel, sorry, I updated the question.
– CoolMind
Nov 14 '18 at 15:41
@RumitPatel, sorry, I updated the question.
– CoolMind
Nov 14 '18 at 15:41
add a comment |
3 Answers
3
active
oldest
votes
you can try this way xml after taking the picture
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
/>
dependencies {
...
implementation 'de.hdodenhof:circleimageview:2.2.0'}
add a comment |
Please check below answer :
Try it and let me know if any question regarding it.
private RequestOptions circleOptions = new RequestOptions()
.centerCrop()
.circleCrop() // responsible for circle crop
.placeholder(R.color.color_gray) // replace with your placeholder image or remove if don't want to set
.error(R.color.color_gray) // replace with your placeholder image or remove if don't want to set
.diskCacheStrategy(DiskCacheStrategy.RESOURCE);
public void loadImageCircle(String url, ImageView view) {
Glide.with(context)
.load(url)
.apply(circleOptions)
.into(view);
}
Call method as :
loadImageCircle(imafgeURL,imageView);
add a comment |
Use RequestOptions.circleCropTransform()
Like this :
Glide.with(this).load(url)
.apply(RequestOptions.circleCropTransform())
.into((ImageView) photo);
Plus, make sure the ImageView is a square. If you are using ConstraintLayout, use app:layout_constraintDimensionRatio="1:1"
Doc : https://bumptech.github.io/glide/javadocs/400/com/bumptech/glide/request/RequestOptions.html
Yes, I have a squareImageView
(50x50). Sorry, but a result is the same.
– CoolMind
Nov 14 '18 at 13:43
@CoolMind then post the xml layout please
– Hocine B
Nov 14 '18 at 14:47
Ok, I added it.
– CoolMind
Nov 14 '18 at 14:52
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53300865%2fmake-square-image-in-glide-and-then-round-it%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
you can try this way xml after taking the picture
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
/>
dependencies {
...
implementation 'de.hdodenhof:circleimageview:2.2.0'}
add a comment |
you can try this way xml after taking the picture
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
/>
dependencies {
...
implementation 'de.hdodenhof:circleimageview:2.2.0'}
add a comment |
you can try this way xml after taking the picture
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
/>
dependencies {
...
implementation 'de.hdodenhof:circleimageview:2.2.0'}
you can try this way xml after taking the picture
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
/>
dependencies {
...
implementation 'de.hdodenhof:circleimageview:2.2.0'}
answered Nov 14 '18 at 13:10
demirseymademirseyma
91
91
add a comment |
add a comment |
Please check below answer :
Try it and let me know if any question regarding it.
private RequestOptions circleOptions = new RequestOptions()
.centerCrop()
.circleCrop() // responsible for circle crop
.placeholder(R.color.color_gray) // replace with your placeholder image or remove if don't want to set
.error(R.color.color_gray) // replace with your placeholder image or remove if don't want to set
.diskCacheStrategy(DiskCacheStrategy.RESOURCE);
public void loadImageCircle(String url, ImageView view) {
Glide.with(context)
.load(url)
.apply(circleOptions)
.into(view);
}
Call method as :
loadImageCircle(imafgeURL,imageView);
add a comment |
Please check below answer :
Try it and let me know if any question regarding it.
private RequestOptions circleOptions = new RequestOptions()
.centerCrop()
.circleCrop() // responsible for circle crop
.placeholder(R.color.color_gray) // replace with your placeholder image or remove if don't want to set
.error(R.color.color_gray) // replace with your placeholder image or remove if don't want to set
.diskCacheStrategy(DiskCacheStrategy.RESOURCE);
public void loadImageCircle(String url, ImageView view) {
Glide.with(context)
.load(url)
.apply(circleOptions)
.into(view);
}
Call method as :
loadImageCircle(imafgeURL,imageView);
add a comment |
Please check below answer :
Try it and let me know if any question regarding it.
private RequestOptions circleOptions = new RequestOptions()
.centerCrop()
.circleCrop() // responsible for circle crop
.placeholder(R.color.color_gray) // replace with your placeholder image or remove if don't want to set
.error(R.color.color_gray) // replace with your placeholder image or remove if don't want to set
.diskCacheStrategy(DiskCacheStrategy.RESOURCE);
public void loadImageCircle(String url, ImageView view) {
Glide.with(context)
.load(url)
.apply(circleOptions)
.into(view);
}
Call method as :
loadImageCircle(imafgeURL,imageView);
Please check below answer :
Try it and let me know if any question regarding it.
private RequestOptions circleOptions = new RequestOptions()
.centerCrop()
.circleCrop() // responsible for circle crop
.placeholder(R.color.color_gray) // replace with your placeholder image or remove if don't want to set
.error(R.color.color_gray) // replace with your placeholder image or remove if don't want to set
.diskCacheStrategy(DiskCacheStrategy.RESOURCE);
public void loadImageCircle(String url, ImageView view) {
Glide.with(context)
.load(url)
.apply(circleOptions)
.into(view);
}
Call method as :
loadImageCircle(imafgeURL,imageView);
answered Nov 14 '18 at 13:14
Deep PatelDeep Patel
1,6952721
1,6952721
add a comment |
add a comment |
Use RequestOptions.circleCropTransform()
Like this :
Glide.with(this).load(url)
.apply(RequestOptions.circleCropTransform())
.into((ImageView) photo);
Plus, make sure the ImageView is a square. If you are using ConstraintLayout, use app:layout_constraintDimensionRatio="1:1"
Doc : https://bumptech.github.io/glide/javadocs/400/com/bumptech/glide/request/RequestOptions.html
Yes, I have a squareImageView
(50x50). Sorry, but a result is the same.
– CoolMind
Nov 14 '18 at 13:43
@CoolMind then post the xml layout please
– Hocine B
Nov 14 '18 at 14:47
Ok, I added it.
– CoolMind
Nov 14 '18 at 14:52
add a comment |
Use RequestOptions.circleCropTransform()
Like this :
Glide.with(this).load(url)
.apply(RequestOptions.circleCropTransform())
.into((ImageView) photo);
Plus, make sure the ImageView is a square. If you are using ConstraintLayout, use app:layout_constraintDimensionRatio="1:1"
Doc : https://bumptech.github.io/glide/javadocs/400/com/bumptech/glide/request/RequestOptions.html
Yes, I have a squareImageView
(50x50). Sorry, but a result is the same.
– CoolMind
Nov 14 '18 at 13:43
@CoolMind then post the xml layout please
– Hocine B
Nov 14 '18 at 14:47
Ok, I added it.
– CoolMind
Nov 14 '18 at 14:52
add a comment |
Use RequestOptions.circleCropTransform()
Like this :
Glide.with(this).load(url)
.apply(RequestOptions.circleCropTransform())
.into((ImageView) photo);
Plus, make sure the ImageView is a square. If you are using ConstraintLayout, use app:layout_constraintDimensionRatio="1:1"
Doc : https://bumptech.github.io/glide/javadocs/400/com/bumptech/glide/request/RequestOptions.html
Use RequestOptions.circleCropTransform()
Like this :
Glide.with(this).load(url)
.apply(RequestOptions.circleCropTransform())
.into((ImageView) photo);
Plus, make sure the ImageView is a square. If you are using ConstraintLayout, use app:layout_constraintDimensionRatio="1:1"
Doc : https://bumptech.github.io/glide/javadocs/400/com/bumptech/glide/request/RequestOptions.html
edited Nov 14 '18 at 18:04
dhilt
7,87742141
7,87742141
answered Nov 14 '18 at 13:06
Hocine BHocine B
30717
30717
Yes, I have a squareImageView
(50x50). Sorry, but a result is the same.
– CoolMind
Nov 14 '18 at 13:43
@CoolMind then post the xml layout please
– Hocine B
Nov 14 '18 at 14:47
Ok, I added it.
– CoolMind
Nov 14 '18 at 14:52
add a comment |
Yes, I have a squareImageView
(50x50). Sorry, but a result is the same.
– CoolMind
Nov 14 '18 at 13:43
@CoolMind then post the xml layout please
– Hocine B
Nov 14 '18 at 14:47
Ok, I added it.
– CoolMind
Nov 14 '18 at 14:52
Yes, I have a square
ImageView
(50x50). Sorry, but a result is the same.– CoolMind
Nov 14 '18 at 13:43
Yes, I have a square
ImageView
(50x50). Sorry, but a result is the same.– CoolMind
Nov 14 '18 at 13:43
@CoolMind then post the xml layout please
– Hocine B
Nov 14 '18 at 14:47
@CoolMind then post the xml layout please
– Hocine B
Nov 14 '18 at 14:47
Ok, I added it.
– CoolMind
Nov 14 '18 at 14:52
Ok, I added it.
– CoolMind
Nov 14 '18 at 14:52
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53300865%2fmake-square-image-in-glide-and-then-round-it%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Better to use
CircleImageView
. It's easy and effective.– Rumit Patel
Nov 14 '18 at 13:12
@RumitPatel, yes, but if I have Glide, probably it can handle cropping.
– CoolMind
Nov 14 '18 at 13:38
1
yes @CoolMind , you wrote you have tried and Glide (v.4) doesn't correctly crop the image. so I suggested alternate and better way. I had same issue and I preferred to use
CircleImageView.
:-)– Rumit Patel
Nov 14 '18 at 13:47
@RumitPatel, thanks. Strange that you have a namesake here. :)
– CoolMind
Nov 14 '18 at 13:54
@RumitPatel, sorry, I updated the question.
– CoolMind
Nov 14 '18 at 15:41