Android application - three questions
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 s开发者_StackOverflow中文版et 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
精彩评论