I have simple job to do. I have to create an Help page for my android application. On that page I want to just put a full page of text of green color with some background image. Can anybody suggest me how can I do this in my XML file. Either in GraphicalLayoutMode or XML mode.
Please suggest what are the components required to this type of Help page...
android:background="#0abcde"
to set a color
android:background="#drawable/filename"
to set a image background.
use these tags for your layout parent view.
Related
Now I have this task where I should create a rating bar just like youtube in my app , and so my idea was to have a textview where I set its background to a color but then remove the color according to an equation I will make so it displays only a percentage of it... any idea how can I do this or where to look ?
The simplest way to do this would be to create a selector.xml. You would assign android:background="#drawable/selector". Your selector would decide which background color to show based on what percentage you have assigned.
This link explains how to use selectors with buttons. It should help to get you on the right track...http://developer.android.com/guide/topics/resources/color-list-resource.html
EDIT: You can still accomplish a custom progress bar by xml. It is very similar to the selector. Just think of it as many more selectors based on progress instead of state. Here is a nice example...Custom Drawable for ProgressBar/ProgressDialog
You can also look into xml animations. They are similar.
For some reason im unable to change the background color of an empty webView in xml using android:background. Although I could change it in java code using something like this:
myWebView.setBackgroundColor(Color.parseColor("#D4CAB4"));
But I prefer to do it in xml and I cant find the reason why android:background is not working?
If one can set WebView background color in xml layout the answer is "NO" and the reason behind is:
Set Background Color of WebView. (XML LAYOUT)
You load data on webView in activity class.
The background you set in the step 1 will be ignored and default color will be set.
The only method left is to set the background of WebView after the data is loaded.
I hope this can help you to understand the case here.
I have an EditText view which I need to look like below (focused and non-focused versions).
Also I have two following images:
Can I somehow just set these images as a background to make EditText look like above, not depending on its width? Or do I need to create some additional image files? Or some other solution? I'm a complete newbie in designing UI, so I'd appreciate any help and any comments on subject.
You first need to create a 9-patch graphic for each of your images. These specify how the image is stretched, and how the content is padded.
Then, you need to create a selector xml drawable to use one image or the other, based on the EditText state.
Hey guys I am having trouble with placing my buttons in my XML layout. I already have a background and was just trying to put 3 buttons near the middle and thats where I'm having trouble. I know about center gravity and all that but could you help me? Also, If I made my own buttons can I just import them using the image button thing, or is that not right? Thanks for the help!
PS: Also, there is a big white box around my button. How do I get that to go away?
I posted this answer to your duplicate question, so I'll also post it here. :)
You can rearrange elements of your layout by editing the XML directly or by dragging and dropping in the outline view or the graphical layout view (I find the latter harder to do reliably).
To use your custom views, click on the "Custom & Library Views" button in the graphical layout palette, or just type in the fully qualified class name as the view tag in the XML.
If you use Image button you can set your custom Image to src property or background property. If youi chose src you should add android:background="#null".
But I would recommend to use background property while if you use 9-patch png (who knows maybe tomorow you will use 9-patch) they would not stretch if you set it in src.
I have a listview in which i have an image and text content getting populated from the java code.
I'm unable to get the default orange selector working on the image. The image is placed ontop of button as setBackgroundResource() from Java.
Can anyone help me with the same?
you could do change background by using drawable property of button in xml file. if you will use this setbackgroundresource() then it will ruin the effect of clicking on it. if u still want to use image as background source then u should create selector xml file for the button background.