Comments (12)
This is the same issue as issue#78.
Quoted from the answer in isssue#78: "You don't need to use RoundedImageView since TextDrawable already supports rounded corners. Just use a normal ImageView."
from textdrawable.
This is exactly what I was trying to Say Zeph.
from textdrawable.
@zephzeph what if I want to load the image from web, if not then use TextDrawable
from textdrawable.
@byandby @zephzeph @caraus @rachitmishra
Hi,
I am using CircleImageView which is a derivative of RoundedImageView, I have not been able to use this library because Bitmap#createBitmap thrown this exception. java.lang.IllegalArgumentException: width and height must be > 0 . Have you guys been able to find a solution to this while using the CircleImageView?
from textdrawable.
ok! awesome, will use that!
from textdrawable.
I've got it working with CircleImageView (https://github.com/hdodenhof/CircleImageView).
What I did was set the TextDrawable to a scale of the length/width of my CircleImageView. For example my CircleImageView is L:56 W:56. I set the TextDrawable to L:112 and W:112 and converted the TextDrawable to a bitmap. Then I passed the bitmap to the CircleImageView.
from textdrawable.
@KtodaZ How exactly do you set L, W? setIntrinsicWidth(500)
doesn't seem to work. Would you mind sharing your solution?
from textdrawable.
Sure. Here is my code below:
private final int circleImageViewWidth = 112;
private final int circleImageViewTextSize = 60;
// Create drawable
TextDrawable drawable = TextDrawable.builder(this)
.beginConfig()
.useFont(Typeface.DEFAULT_BOLD)
.fontSize(circleImageViewTextSize)
.height(circleImageViewWidth)
.width(circleImageViewWidth)
.endConfig()
.buildRound(Character.toString(firstName.charAt(0)).toUpperCase(), color);
// Convert to bitmap (generic solution found on stackoverflow)
if (drawable instanceof BitmapDrawable) {
BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
if(bitmapDrawable.getBitmap() != null) {
return bitmapDrawable.getBitmap();
}
}
if(drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) {
bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888); // Single color bitmap will be created of 1x1 pixel
} else {
bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
}
Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
drawable.draw(canvas);
return bitmap;
and my recycler_text_view.xml
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/circleImageView"
android:layout_width="56dp"
android:layout_height="56dp"
android:src="@drawable/ic_contact_picture" />
@divonas Hope this helps
from textdrawable.
@KtodaZ Thank you for sharing.
from textdrawable.
For anyone having problems with RoundedImageView, just set width and height in the TextDrawable builder. This way the RoundedImageView will be able to display it.
from textdrawable.
@divonas you rock, setting the height and width is all that's needed. I'm using com.makeramen.roundedimageview.RoundedImageView
from textdrawable.
text color is not set even after setting the color
alPha = TextDrawable.builder() .beginConfig() .height(40) .width(40) .useFont(ViewUtils.getMontesaratfont()) .textColor(R.color.white) .endConfig() .buildRound(letter, generator.getColor(position));
this is my code
from textdrawable.
Related Issues (20)
- how can we make 2 lines in the TextDrawable ? HOT 1
- Unable to fetch artifact from maven repository HOT 1
- Does lib support dynamic changing on "text" on the drawable.
- Please update project SDK 25 HOT 1
- How to change background and text color same time? HOT 1
- Text + textDrawable Image
- how to put letter image from adapter class for listview or gridview
- Wont work with Glide... HOT 1
- Cannot resolve .builder()
- Color Generator Config
- Custom Color not assuming HOT 1
- Random color doesn't work HOT 1
- How to use it as BottomNavigationView item?? HOT 2
- does not work with CircleImageView HOT 2
- Doesn't work with LayerDrawable
- tt barecodr
- Can you please publish your library to a Maven Central ? I can offer you some help for this HOT 6
- ارسل التفاصيل
- .c
- ImageWebView
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from textdrawable.