2

I am using theme as:

<style name="CustomActionBarTheme" parent="@style/Theme.AppCompat">
    <item name="android:windowActionBarOverlay">true</item>

    <!-- Support library compatibility -->
    <item name="windowActionBarOverlay">true</item>
</style>

I want to show the ImageView partly behind the the ActionBar. I have tried Show ImageView partly behind transparent ActionBar and searched on google, but can't find the appropriate solution.

Community
  • 1
  • 1
Nitish Jain
  • 704
  • 2
  • 10
  • 24

1 Answers1

0

Better use Toolbar or Support Toolbar

With Toolbar, you can add it in your XML File just like any other View.

In your Activitys onCreate call setActionBar(toolbar) / setSupportActionBar(toolbar)

Or try to add these two lines in your style:

<item name="android:windowActionBarOverlay">true</item>

<!-- Support library compatibility -->
<item name="windowActionBarOverlay">true</item>

But using the Toolbar is actually pretty simple and the new standard.

Read this to get started: http://android-developers.blogspot.de/2014/10/appcompat-v21-material-design-for-pre.html

Bene
  • 724
  • 8
  • 20
  • Hey I have edited the code which I am using, but the ActionBar doesn't become translucent as I was thinking of using the second approach, Is something wrong the way i am using Appcompat... Also can you provide the code describing how to use toolbar to make actionbar translucent.. – Nitish Jain Mar 20 '15 at 12:06
  • 1
    Use a ColorDrawable, set its alpha to 0 and set it as the ActionBars background. ColorDrawable cd = new ColorDrawable(); cd.setAlpha(0); actionBar.setBackgroundDrawable(cd); With ToolBar it's pretty much the same. – Bene Mar 20 '15 at 13:06
  • Hey thanks it worked but it makes transparent action bar whether I use 128 or 255 or 0 in setAlpha function, I want translucent action bar... – Nitish Jain Mar 20 '15 at 15:04
  • I added: ColorDrawable cd = new ColorDrawable(R.drawable.picture); cd.setAlpha(128); getSuportActionBar.setBackgroundDrawable(cd); then worked... BTW thanks a lot – Nitish Jain Mar 20 '15 at 16:06
  • ColorDrawable takes a color as argument, nor a resource ID. Like getResources().getColor(R.color.someColor); Glad it works ;) – Bene Mar 20 '15 at 17:04