7

The problem is the following one : on one of my activities, I needed a custom layout for my action bar, and the only way to do it like needed was to have a transparent ActionBar over my screen. In order to do that, I marked the ActionBar as overlay, and specified the action bar background as transparent. This works when using Android >= 15, but in 14 and below, the ActionBar keeps its bottom border. I tried anything to remove it, with no avail.

Here is a picture to see it more clearly :

On API 14 : ActionBar on API 14

On API 16: ActionBar on API 16

The design is the following : the Action Bar is supposed to be transparent and in overlay mode, and behind it there is a background + the logo

<ImageView
 android:id="@+id/action_bar_background"
 android:layout_width="match_parent"
 android:layout_height="@dimen/action_bar_accueil_total_height"
 android:layout_alignParentTop="true"
 android:contentDescription="@string/action_bar"
 android:scaleType="fitXY"
 android:src="@drawable/actionbar_logo_extended" />

<ImageView
 android:id="@+id/home_gallica_logo"
 android:layout_width="@dimen/largeur_logo_carrousel"
 android:layout_height="@dimen/action_bar_accueil_total_height"
 android:layout_alignParentTop="true"
 android:layout_centerHorizontal="true"
 android:contentDescription="@string/action_bar"
 android:src="@drawable/logo_fullcolor" />

Some precisions : I use ABS, but this does not seem to be the source of the problem, as switching to the v7 support library did exactly the same thing.

Do anyone has an idea how to remove this bottom border ?

Valentin Rocher
  • 11,667
  • 45
  • 59
  • Well I guess it's all about how the different version interpret the `.png` images. Can you set the background of the image to be like the gradient of the background. I'll be searching about my hypothesis. – g00dy Aug 06 '13 at 14:48
  • The fact is that the ActionBar is supposed to be transparent (and in overlay), in order to see the image below it. – Valentin Rocher Aug 06 '13 at 15:20
  • Ok let me ask you this, how come the horizontal line dissapears only partially on API 16 - is the image that long (in width)? And what i noticed also, on API 14 you have doubled line behind the logo, which dissapears as you want, but the second line is visible. This makes me wonder - could you paste the resources here so I can see them - the image for the logo (on a tiled background, with the sizes of it), the image (gradient.xml or normal image gradient) that you use for the ActionBar + the whole `xml` if that's not a problem? – g00dy Aug 06 '13 at 15:32
  • The "second" horizontal line is not a real one : it's part of the image I put *behind* the ActionBar. That's why you can see it in both API 14 and 16. I'll try to post the XML tomorrow if I can – Valentin Rocher Aug 06 '13 at 15:45
  • @g00dy : I added the XML in order to explain more clearly – Valentin Rocher Aug 07 '13 at 08:00
  • I have a suggestion here - for the `ImageView` with id of `action_bar_background` - set the attribute `android:background="@drawable/actionbar_logo_extended"` and `android:src="@drawable/logo_fullcolor"`. This way, you can more easily distinguish between the background and the foreground. What I also noticed - on API 14 the logo is smaller than on API 16, but the icons to the right are bigger, why is that? Please to also paste the logo image, i need to know the exact contents of it and the transparency span on it. Thanks – g00dy Aug 07 '13 at 08:23
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/34978/discussion-between-valentin-rocher-and-g00dy) – Valentin Rocher Aug 07 '13 at 09:55
  • Out of curiosity I've made a small test but I didn't managed to see the behavior you talk about. Here's what I've done https://gist.github.com/luksprog/6191716 – user Aug 09 '13 at 07:19
  • @Luksprog : it seems like some other parameter in my theme is causing this problem. Following your advice, I've tried removing some parameters and it nearly works. As soon as I've found the culprit I'll post an answer – Valentin Rocher Aug 09 '13 at 08:25
  • @Luksprog : as your comment helped me solve the problem, could you post an answer, in order for me to give you the bounty ? The only other answer is helpful concerning ActionBar, but not in my case. – Valentin Rocher Aug 09 '13 at 08:35

3 Answers3

3

Following the advice and the test by Luksprog in the comment, I used Theme.Sherlock (instead of Theme.Sherlock.Light) in my action bar for this page, and copied from my old theme the settings I needed. This seems to have resolved the problem, but I'm not completely sure of the source. The only advice I can give to people who are going to see this will be to use Theme.Sherlock.

Community
  • 1
  • 1
Valentin Rocher
  • 11,667
  • 45
  • 59
3

I've tried to make a simple activity to showcase the behavior but I didn't manage to do it. I used an Activity with the theme Theme.Sherlock:

android:theme="@style/Theme.Sherlock

and to make the overlay(in the onCreate() method):

requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); // Window from com.actionbarsherlock.view
//...
setContentView(content);
ActionBar ab = getSupportActionBar();
ab.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
user
  • 86,916
  • 18
  • 197
  • 190
0

You can hide the action bar at by calling hide() method:

ActionBar actionBar = getSupportActionBar();
actionBar.hide();

Or you can set this in your manifest if you want to hide it permanently:

<activity
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
>
Sergey K.
  • 24,894
  • 13
  • 106
  • 174