Android application - three questions - android

I am writing an Android application at the moment, no knowledge of java what so ever, except what I have learnt in the last 5 hours. I've managed to implement a two screens and a nice looking layout.
I have three questions:
How do I set the Action Bar on Honeycomb to be transparent like in the Google Maps application? I want to be able to partially see the background graphic through it.
What code to use to empty five edit texts and a textview on button click? I've read something about a viewgroup, but I have no idea how to implement that...
I have a linearlayout with a tablelayout centred horizontally and vertically inside it, and eleven table rows in that. How do I set a partially transparent black as a sort of fill colour for the tablelayout without ruining the background of the linearlayout? Every time I try to set a fill colour it blacks out the entire background image of the layout surrounding it as well.
Plain english would be preferable because I am so new to this.
Thanks heaps for any replys, have a great day.

For the first question, I think you can do like below:
In the onCreate() method, before the setConentView() add:
getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
The Android system will automatically set background fill the whole screen.
create a transparent sharp "mysharp.xml"like below:
<?xml version="1.0" encoding="utf-8"?>
<shape>
<solid android:color="#55000000" />
</shape>
set the action background
getActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.mysharp));

you can also declare action bar overlay in xml by
<item name="android:windowActionBarOverlay">true</item>
just like here http://developer.android.com/resources/samples/HoneycombGallery/res/values/styles.html

Answer to your 1st question: You can implement a theme on the HoneyComb action bar. Check this link for more info. The color would be something like this: #29000000.
The first hex 2-digit(#29) represents alpha channels of color and set opacity. If value is “00” that means 100% transparent. if value is set it will be opaque, it can be any value in 00 to FF.
More links on styling the Action Bar:
http://android-developers.blogspot.com/2011/04/customizing-action-bar.html
Example project is to be found here:
http://p-xr.com/customizing-the-action-bar-in-honeycomb/

In my Android 3 application I used
// Makes Action Bar Transparent
requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
actionBar = getActionBar();
actionBar.setBackgroundDrawable(null);
// END
and now the action bar is 100% transparent, Except for the stuff I add to it of course :)
Cheers

Related

How to color a portion of a view in android?

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.

Changing the color of the spinner

In this picture you can see (barely lol) that the spinner icons that rest on the bottom and bottom right are very hard to see due to the black background that I am using. What would I need to do to make that greyish looking color to white or any color for that matter?
Try this tutorial:
Android Custom Spinners
A similar process is used for working with custom buttons and other elements.
Updated as the link is broken. Try this stackoverflow answer
Spinner Background Design

Why my ProgressBar looks different in different layouts

I used style="?android:attr/progressBarStyleLarge" to create the spinning ProgressBar.
Not sure why in different layout XML it behaves differently(I am using the same device).
It shows as a blue spinning circle and a circle of gray dots. I want to use the blue spinning circle in all my pages..
please advise!
Sorry that I don't have the reputation to upload pictures.
I think its dependent on background color of the layout. once put all layouts background color to black or some unique color. Then it will look uniquely.
If you want to put as unique for all pages the solution is:
Maintain same background color for all views
Otherwise use custom progress bar.

android how to change the progressbar color programatically

How can you change the progressbar color from within the app. I already have it set in the XML but as the value gets within preset thresholds I need to change the color of the bar to alert the user. For the buttons I can set it like the example below. Is there a way to do with with the progressbar?
B.setBackgroundDrawable(c.getResources().getDrawable(R.drawable.button2));
B.getBackground().setColorFilter( UserS.ColorBtnBack, PorterDuff.Mode.MULTIPLY);
I posted a tip as a comment on your other question, see http://colintmiller.com/2010/10/07/how-to-add-text-over-a-progress-bar-on-android/
Scroll down to "Bonus Tip", which discusses changing color. I guess you want a predefined set of colors, which you could then switch between using setProgressDrawable()
ProgressBar uses a LevelListDrawable with setProgressDrawable() to determine the color of the bar. You can try assembling a LevelListDrawable in Java, though I have never tried that -- I have only defined them via XML.

Android TabWidget set background color error

I have been trying to apply a style to my TabWidget.
I've tried several methods such as
for(int i=0;i < tabHost.getTabWidget().getChildCount();i++) tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#7392B5"));
from
How do I change the background of an Android tab widget?
However, this code does not work for me. I've also tried messing with some XML styles. The closest I have gotten is to set the Divider, however that makes the entire tab widget turn one solid color and the Tabs are no longer drawn on top.
Please help. Mark's books only touch on setting the Icons for the tabs, not changing the color. I feel this should be simple, but TabWidgets and Hosts make everything harder.
I've tried this code targeting both the 1.6 and 2.2 platforms, but neither API works.
Thanks
The background of a tab is actually a NinePatch image, set into a StateListDrawable. When you call setBackgroundColor(), you're replacing the set StateListDrawable with a simple color, so the entire tab turns into that color. What you'll need to do is actually modify (or draw your own) NinePatch tab images that are the color and style that you want for each state (e.g. focused, pressed, etc.).
Alternately, in code you could set a ColorFilter as described here (getBackground() will work for a TabWidget as well as a button) but I'd recommend going the NinePatch route personally.

Categories

Resources