How to edit TextView Android? - android

I want to load a text file in Android with custom size and color just as shown in the website (download the 1.html file). This is a HTML file and I have used WebView to show the file but I want to show using TextView. If I simply copy this in Text file it deletes the custom color and the size. Is there any easy way using Java code like loop or something to make specific lines in Red color and the other in black to make it look like it's shown in HTML File?
https://sites.google.com/site/gurbaniujagar/page1
Thanks in advance

Take a look at this site here, it shows you all you need to know.
http://javatechig.com/2013/04/07/how-to-display-html-in-android-view/

Related

How to show html code on button in Android and style it

I want to put html codes on buttons as text in my android application and style them.
For ex: I want to create a help button and put "❔" as text to it.
Below is the code I have written in the activity.
Button btHelp=((Button) findViewById(R.id.btHelp));
btHelp.setText(Html.fromHtml("❔"));
But if I want to change the color of it. I tried by giving span and font in the above statement but it is not applying.
Can you please let me know how to give the colors for this. Also let me know if there is any better way to do so.
Thanks,
If you want to change text color, simply use:
btnHelp.setTextColor(Color.parseColor("#FF0000"));
or
btnHelp.setTextColor(Color.RED);
or
btnHelp.setTextColor(getResources().getColor(R.color.red));
But that won't work with emojis like your White Question Mark Ornament. If you want to change that question mark color, you will have to make a drawable file with button drawables (png) that have that question mark with the color you want. You can do that from photoshop or any other program.

How to show XML files in Android TextView

I need to show an XML file inside a TextView in Android. I just want the code highlighter effect, which shows the various XML keywords or tag with specific colors.
Is there any library I can use or I have to built it up myself?
Thank you guys.

Simple RichText Editor in Android

i want to create a simple rich text editor in android, just like this application on google play store: https://play.google.com/store/apps/details?id=com.spn.richnotepad&hl=en
and i am very new in android so anyone can provide some idea about it.
Thank You
It's not difficult at all but before you start I highly recommend you to read the guide from Android Developer site:
https://developer.android.com/training/basics/data-storage/index.html
You will learn how to save data which is a very important part of your project.
Then you have to learn all about EditText (allows the user to type text into your app) and TextView (displays text on screen).
http://developer.android.com/guide/topics/ui/controls/text.html
When your app is finished you can add some additional functionality:
Spelling Suggestions
https://developer.android.com/training/keyboard-input/index.html
Text Formatting
http://www.chrisumbel.com/article/android_textview_rich_text_spannablestring
Font Style
http://code.tutsplus.com/tutorials/quick-tip-customize-android-fonts--mobile-1601
Some useful links:
http://developer.android.com/reference/android/widget/EditText.html
http://developer.android.com/reference/android/widget/TextView.html
I also advice you this Notepad Tutorial which will guide you step by step to construct a simple notes list that lets the user add new notes.
http://developer.android.com/training/notepad/index.html
Check out this one https://github.com/chinalwb/Android-Rich-text-Editor, it is still in progress but you may get some pointers from there. Thanks.
Supported styles:
Bold
Italic
Underline
Strikethrough
Numeric list
Bullet list
Align left
Align center
Align right
Insert image
Background color
Hyper link
#
Quote
Foreground color
Emoji icon
Superscript
Subscript
Font size
Video
Image from internet
Dividing line
All styles support save as HTML file
Set init html content and continue editing or displaying
Demo for part of the supported features
Found some quick solutions :
droid-writer
cwac-richedit
Also check following discussions:
Rich Text Box in android
Implementing a rich text editor in Android?

HTML android in android

I want to develop an editor which can make the text bold, italics and underline and create an equivalent HTML for it. I have somethhing like this in my mind:
When the user clicks on save, I should get HTML data.
For example , if user writes:Hello World
then I should get <!Doctype HTML><body>Hello <b><i>World</i></b></body></html>
What are my options here? are there any previous projects like this or do i have to make this from scratch?
You can use Character Style sub-classes of Android for the styling of your texts. Then use HTML class to get the HTML equivalent of your text. I'm currently developing one and those are the ones I used. You may also check out https://github.com/commonsguy/cwac-richedit for an example on how you could use Character Style for editing. :)

Change Background In Java Code

I am working on a simple app and I want to change the background image. Right now it's just a plain color. I want to be able to use an image from the web by changing the URL in the Java Code. So what I need to know is how to change this tag from the XML android:background="#FFFFFF" to some image I found at the following website:
You can't link an image from the web directly in the xml declaration of a View. You either download the image and then put it in the drawable folder and reference it like this:
android:background="#drawable/name_of_the_image"
or (in java code) you parse that address, obtain the image and then set it as background in code in your activity.
I think you need the View.setBackgroundDrawable(Drawable d) method.

Categories

Resources