I have been trying to make an ActionBar for a while now. At first I decided just to draw it as an image (2nd actionBar in the image below) but noticed that on some of the devices that Image wouldn`t take up the whole screen width. As for the original ActionBar I use this code in my main Activity onCreate method:
final ActionBar actionBar = getActionBar();
@SuppressWarnings("deprecation")
BitmapDrawable background = new BitmapDrawable (BitmapFactory.decodeResource(getResources(), R.drawable.actionbar));
actionBar.setBackgroundDrawable(background);
//actionBar.setIcon(android.R.color.transparent);
actionBar.setDisplayShowTitleEnabled(false);
The first ActionBar has a light theme with the image being stretched. How can I make it to be transparent and is there a way to set ActionBar height so it wouldn`t look that stretched ? I also tried doing this with styles and had the same result.
EDIT I followed vinitius answer so I now have this: result the image is 482x104 and my phone is 480x800. This is the same problem that happened when using it as plain image. Image is in drawable-hdpi folder.
EDIT 2 by adding android:scaleType="fitXY" to the ImageView it will make the whole image stretched.
actionbar_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#00000000"
android:orientation="vertical" >
<View
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#3383A8" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:src="@drawable/actionbar" />
</RelativeLayout>
EDIT 3 If I add the image as a RelativeLayout background it fill not fit in the whole width on the bigger devices. If I use it as an image on bigger width devices it will be stretched. Image