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.
Related
Hi I am a beginner in android and I want to know how to customize buttons,check box etc., I searched in web but found many ways and got confused...
Can you please tell me what are the ways to customize android widgets, can we do that using css, like we do for the HTML?
Thanks in advance...
There are a few ways. You can use 9patch to edit the files inside the SDK(which will typically be C:\Android\SDK\platforms\android-19\data\res\drawable-hdpi) - Android-19 is the api level, and then set them in your xml layout under the widget you want with
android:background="#drawable/your file"
Another way is to create a selector(Recommended because it can handle stuff like when clicked and more), shape(Simple creation with corners and stuff), layer list(Advanced selector) or solid(just a color) in /drawable and then set them in your xml under the widget you want with
android:background="#drawable/your file"
An example of the second solution can be found here android button selector
I'm learning to develop android apps and in the process I realized that there two ways to get a job done. Using xml or normal code. Suppose I want to change the position of a button, I'll be doing it in xml using align left/align centre etc., This will be done in the XML file. If I want to achieve the same through code, where should I place the code ? Inside which class ?
There are two aspects to your question that I understand.
1. Creating a whole layout file dynamically (without XML).
2. Creating a layout through XML and changing the components positions and properties dynamically through your activity file.
Now, it's upto the developer what he wishes to choose.
To help you further, please view this video link posted by the Android team.
It's all about layouts and includes how to layout apps using Java, not XML. However, you are warned that the android team wants you to use XML.
The code will be placed in the same class as the class where you reference your xml code. Do a read up in your android docs for insight.
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/
I recently discovered that you can describe an Android custom drawable in an XML file, which you can then use with a button (and other View, I guess), and this inspired me to ask this question:
Does anyone know (or know where I can find) an XML file that precisely describes the exact default button that shows up in an Android application if you don't change a single detail.
It seems to me, that would be a very helpful starting point.
Thanks,
R.
//this is an nice tutor for gradient
This time, all those gradients are created programmatically which gives you total control of the button and the gradient!
link here:
The default Android Views, like Button, and its selector XML files are available in resource folder of particular Android platform.
For example,
\android-sdk-windows\platforms\android-8\data\res\drawable folders.
These drawables and XML files are accessible in our application code, using 'android.R'.
For example: android.R.drawable.btn_check
please is possible to make some activity with images, text etc. via some .java file (Java programming) without xml? - xml use only for strings of text, for multilanguage....
Thanks for help.
Yeah it is possible and we call it Dynamic Layouts. But i think you should stick to XML because it is easier to use as compared to programmed layouts. I know XML layout could be an headache sometime but once you'll be habitual to these XML layouts stuff then you won't find it hard any more. And if there is any other reason behind why you asked this question then yes it is possible as Android SDK provides classes for each and every layout element with the same name as used in XML file.
For ex. you can create a TextView like this in an activity:-
TextView textView = new TextView(this);
now you can call any function on it which would work similar to TextView's properties used in XML file for ex. for android:text property you can use :-
textView.setText("I am a TextView");
And if you want to know more about these Dynamic layouts then you should spend some time on developer.android.com.
I hope my answer will be useful for you.
Anything that can be done using the xml files can also be done using code. You can create your views manually, add TextView and ImageView to a LinearLayout (or another ViewGroup), etc.
The android developer website contains all the documentation to do this.