devunwired / textdrawable Goto Github PK
View Code? Open in Web Editor NEWTextDrawable implementation and sample use project
Home Page: http://wiresareobsolete.com/wordpress/2012/12/textdrawable-draw-some-text/
TextDrawable implementation and sample use project
Home Page: http://wiresareobsolete.com/wordpress/2012/12/textdrawable-draw-some-text/
There is an error in the measurement code that truncates the measured width instead of rounding up. As a result, some text prematurely wraps since the width is 1pixel short.
I'm trying to put text into ShapeDrawable
TextDrawable d = new TextDrawable(this);
d.setText("SAMPLE TEXT\nLINE TWO");
d.setTextAlign(Layout.Alignment.ALIGN_CENTER);
ShapeDrawable sDrawableref = new ShapeDrawable(new OvalShape());
sDrawableref.setBackroundDrawable(d) //not possible
how can use this TextDrawable for Shapes like OvalShape, RectShape ?
OvalShape oshape=OvalShape();
sDrawableref.setBackroundDrawable(d)//not possible
In TextDrawable:
public int getOpacity() {
return mTextPaint.getAlpha();
}
Does not pass Android Inspection :
Must be one of: PixelFormat.UNKNOWN, PixelFormat.TRANSLUCENT, PixelFormat.TRANSPARENT, PixelFormat.OPAQUE.
java.lang.RuntimeException: Unable to start activity ComponentInfo{br.org.fbb.baldecheio/br.org.fbb.baldecheio.ListaCalculos}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at br.org.fbb.baldecheio.ListaCalculos$PlaceholderFragment.onCreateView(ListaCalculos.java:102)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1786)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:953)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1136)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1499)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:548)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1171)
at android.app.Activity.performStart(Activity.java:5241)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2157)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
The color of the text does not update when used with a ColorStateList
:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:color="@color/gray_6"/>
<item android:state_selected="true" android:color="@color/gray_6"/>
<item android:state_focused="true" android:color="@color/gray_6"/>
<item android:color="@color/highlight_blue"/>
</selector>
textDrawable.setTextColor(getResources.getColorStateList(R.color.highlight_text));
This can be fixed by invalidating the view on state changed:
@Override
protected boolean onStateChange(int[] state) {
// Upon state changes, grab the correct text color
if (updateTextColors(state)) {
invalidateSelf();
return true;
}
return false;
}
I've tested this on 4.0.4, 4.4.2 and 6.0.1. Happy to send a PR if you'd like.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.