I am trying to find an effect in text view android just like the below image.
This is a textview with border in the text:
Can anyone suggest me something to get this effect.
Thanks in advance :)
MagicTextView will do text outlines, amongst other things.
<com.qwerjk.better_text.MagicTextView
xmlns:qwerjk="http://schemas.android.com/apk/res/com.qwerjk.better_text"
android:textSize="78dp"
android:textColor="#ff333333"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
qwerjk:strokeColor="#FFff0000"
qwerjk:strokeJoinStyle="miter"
qwerjk:strokeWidth="5"
android:text="Magic" />
Note: I made this, and am posting more for the sake of future travelers than the OP.
It's borderline spam, but being on-topic, perhaps acceptable?
sourcehttps://stackoverflow.com/posts/10294290/edit
Related
So I'm having a few problems with compiling my app after declaring the android:background value of an ImageButton to android:color/transparent". I've read this is the correct way to avoid having a grey border around the image from a relative post, which you can view here.
The exact error message I'm getting is the following:
Error:error: 'android:color/transparent' is incompatible with attribute android:background (attr) reference|color.
I have no idea why I'm getting this error, so if anyone has any ideas, please give me a shout as this is beyond frustrating!
Thank you.
add # before android:color/transparent
you need to write
android:background="#android:color/transparent"
I'm making an app in my native language Sindhi.
Note: Sindhi language has 52 alphabets, like this
**ا، ب، ج،ف، ڪ**
I have installed Sindhi fonts on my PC, also I have the unicodes of Sindhi.
Problem
When I set text on my Button, like this
<Button
android:id="#+id/btnSindhiLessons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="30dp"
android:text="سنڌي سبق"
android:textSize="30sp" />
It shows perfectly on the code view but in design view it's showing something like this:
but on device or emulator it renders like this:
Notice that one letter is missing. I'm using Android 4.0.4
It's because Eclipse doesn't support Sindhi. While in your device it may support of it's 4.0+, I'm not sure it'll look good if you have an early android device.
check this out.
you are copy pasting the text directly to the code:
use uni code:
like this: \u0623,\u0623,\u0623,\u0623 for your every character
or
get supportive type face,which support sindhi.
one i know that is jameel noori nastaleek
hope it will solve your issue
Follow below steps :
Find best font for Sindhi
Place that font to your asset folder
Set this font as typeface to your button
Please have a look at the following image.
This is a text view which I need in my next android app. However, I really don't know how to implement this kind of textview. I only know how to put a normal rectangle style textview. So, how can I achieve this? If textview is not possible, what are other options?
The simplest thing to do is to create an image (a 9patch would be perfect) and put your text over it.
I did a little image for you. Give it a try:
https://docs.google.com/file/d/0B-Ax5zr61_Dvb2QwcmtWUml1Q2s/edit?usp=sharing
Otherwise you can use a Layout that will wrap your TextView (with the rectangle background) and the image of the little triangle below.
You can also try to "paint" it (using Canvas I guess), but seems overkilling to me.
I am new in android development. I am trying to use a GridLayout to fulfill my UI design.
This is the scenario:
I defined a GridLayout in xml file as following
<GridLayout
android:id="#+id/gridLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#id/linearLayoutBottomLeft"
android:layout_alignParentLeft="true"
android:layout_below="#id/linearLayoutTopLeft"
android:layout_toLeftOf="#id/textView" >
</GridLayout>
Then, I set it in my activity's onCreate() method like following:
GridLayout gridLayout = (GridLayout) findViewById(R.id.gridLayout);
gridLayout.invalidate();
int rowNumber = 4;
int colNumber = 4;
gridLayout.setRowCount(rowNumber);
gridLayout.setColumnCount(colNumber);
so far so good, everything is working well.
However, I also have some buttons there. In button's click event, I changed the rowNumber and colNumber, set them at runtime. It cause some error I think...
So my question is whether the row number and column number can be set at runtime for gridLayout.
If this is not allowed in android, what is a good practice to realize a GUI like what I described above.
Any help would be appreciated.
You'll need to do a gridLayout.removeAllChildren().
Invalidate is a way of letting the View system know that the content of the View has changed and that it needs to be redrawn.
Today, I figured out some way to solve this problem.
In the xml file, I replaced the GridLayout with a LinearLayout, and made the girdlayout dynamically added as the child of linearlayout. Now the row/column count can be changed in button click event handler.
I am not sure if this is a good way to do it and any performance hit will arise.
Need to add it to textview, for example, standard java-code.
What do you exactly mean? You may want to change Typeface of TextView to monospace, this will make your TextView look similar to code block here at stackoverflow.
This font is monospace
Code to make it look like this:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:typeface="monospace"
android:text="This font is monospace" />
or in Java:
yourTextview.setTypeface(Typeface.MONOSPACE, Typeface.NORMAL);
Edit:
So, you need some Java code formatting library, the best would be if it returned result in HTML code, so it could be easily put into TextView.
I don't know if there is something like this for free, but here are few resources you may be interested in:
How to pretty print XML from Java?
Stand-alone Java code formatter/beautifier/pretty printer?
Edit2:
You may also use one of these JavaScript libraries:
http://alexgorbatchev.com/SyntaxHighlighter/
http://code.google.com/p/google-code-prettify/
along with custom WebView to show pretty formatted code.