开发者

Android application - three questions

开发者 https://www.devze.com 2023-03-04 10:25 出处:网络
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 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:

  1. 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.
  2. 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...
  3. 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:

  1. 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.

  2. create a transparent sharp "mysharp.xml"like below:

    <?xml version="1.0" encoding="utf-8"?>
    <shape>
        <solid android:color="#55000000" />
    </shape>
    
  3. set the action background

    getActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.mysharp));
    


  1. 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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号