How to display the Sindhi Language fonts? - java

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

Related

How do I print an Emoji as the text of a button?

I have tried hexadecimal values for the emoji in the text field but it did not work. I'm new to android studio 😂. Do I need to code it in? Or can I add it to the layout? Or both? Thank you
As we found out in the comments, the solution would be to put the code directly into the Java source e.g:
System.out.println("Hello world 😂");
Or the XML source:
<TextView
android:id="#+id/text_view_id"
android:text="😂" />

Unable to Set Text Size Using FlowTextView

I found a library which allows an app to wrap text around an image - however once implemented it changed the size of my text - how can the text size be increase when using this library?
android:textSize= has no impact on the text size.
Neither does:
FlowTextView titleTv = (FlowTextView) findViewById(R.id.titleTv);
((FlowTextView) findViewById(R.id.titleTv)).setTextSize(20);
https://code.google.com/p/android-flowtextview/
Example:
<com.pagesuite.flowtext.FlowTextView
android:id="#+id/titleTv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:text=""
android:textSize="20sp" >
In the short term a call to invalidate will probably get it working:
FlowTextView titleTv = (FlowTextView) findViewById(R.id.titleTv);
titleTv.setTextSize(20);
titleTv.invalidate();
However, I suspect you are using the JAR file right? It is quite out of date so I would recommend checking the source code out and using it as an android library project - setTextSize() should work properly then without needing a call to invalidate() (plus various other bug fixes etc).
Also - I never added the ability to set the text size via XML - wouldn't be too hard to add this though.
I checked the code of android-flowtextview and they have the text size hardcoded (check line 131 here). You have to change their source code or use the public method setTextSize(int).
Also, this link might help you, as seems that someone already did something as you are trying to do.
https://code.google.com/p/android-flowtextview/source/browse/trunk/src/com/pagesuite/flowtext/FlowTextView.java
There's a 'setTextSize(int)' method that should do exactly what you're looking for.
If you want to set it from XML, it's a little more involved. Since FlowTextView's constructors ignore the AttributeSet that gets passed in, you'll have to code this yourself. Follow guides like this: http://kotikan.com/blog/posts/2012/09/android-attributes to figure out how to add custom attributes to your views.

Android: XML Textview text Property

I had seen an Android Tutorial that allows a simple android:text just like the example bellow:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Android Application"
android:textColor="#ffffff" />
But in my eclipse,
it says:
[I18N] Hardcoded string "Android Application", should use #string resource
What should I do?
I need to insert a lot of Text just like,
Accounting has begun since time immemorial. Consider this truth: God said unto Noah; “and every living thing of all flesh, two of every sort shall thou bring into the ark, to keep them alive with thee; they shall be male and female. Of fowls after their kind, and of cattle after their kind, of every creeping thing of the earth after his kind, two of every sort shall come unto thee, to keep them alive. And take thou unto thee of all food that is eaten, and thou shall gather it to thee; and it shall be for food for thee, and for them.” The Bible – Genesis 6:19-20. “Of every clean beast thou shall take to thee by sevens, the male and his female: and of the beast that are not clean by two, the male and his female. Of fowls of the air by sevens, the male and the female; to keep seed alive upon the face of all earth.” The Bible – Genesis 7:2-3
Any suggestion or tell me what the better thing to do?
This is just a warning.
But by using a string resource, you can support multi-languages.
You have just to create a new string resource in the file strings.xml (res/values/strings.xml).
Then add the line :
<string name="your_name">Your text</string>
and just change :
android:text="Android Application" by android:text="#string/your_name"
Now if you want to add a new language to your application, let's say in french, you will have just to create a new folder in the res folder called values-fr and copy/paste the file strings.xml you already have and finally translate the strings you have defined (i.e <string name="your_name">Your text translated in french</string>)
You can have a look at this (problem resolved using screenshots).
You can use hardcoded strings in your layout (or in code), it is just a warning and eclipse won't fail on compilation.
But android best practice is the remove all strings and texts from your app and layout and put it in one place- so it will be much easier to translate later.
So what eclipse suggest you is to extract the "Android Application" text to strings.xml file (that should contain all your app's strings).
If it's just for the tutorial you can ignore it, or even better- just let eclipse extract the text to strings.xml using quick fix

How can I add a source code with markup?

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.

Android string.xml error for every character I type

I am going through the android hello world tutorial, and have been stuck when trying to create an XML UI. For some reason, even on a new program, in which I have made no changes to the default build, it gives the error java.lang.NullPointerException after every character I type. I can't figure out why it is doing this, as I am just trying to edit the text between the Text I want to set it to say something other than what is set by default. However, even with a fresh build, no changes, and I just try to change the text within the xml tags, it still gives the error. What do I need to do to allow it to let me type? I am using the eclips IDE and the android sdk. I was able to do the first part of the tutorial that doesn't involve XML.
Just guessing, but I suspect you are doing something like the following:
<TextView android:text="#string/hello" />
and you are editing it to
<TextView android:text="#string/helloWorld" />
without creating a reference in res/values/strings.xml .
If this is the case, go to strings.xml and edit the proper string there, for example
<string name="hello">Hello World!</string>
becomes
<string name="hello">Hello everybody!</string>
Ok, I finally found the answer somewhere else, it was something wrong with how the file was created by default. I have to add the element xmlns:android as follows <resources xmlns:android="http://schemas.android.com/apk/res/android" />
Interestingly enough, the file will work if I type it one character at a time, dismissing the pop up with each keystroke. However the new element eliminates the pop ups. I am not sure why the error would pop up, yet the program still compile and run correctly on my avd. Oh well, if you have this error add the element and it goes away
I think in your typing contain UTF-8 not pure ASCII. You can change in eclipse by
in Ecipse IDE Window> preference> Under General tab, select workspace.
In text file encoding choose other, in these choose UTF-8 . It will be ok

Categories