1

enter image description here The code used in all the activites is:

    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.mytitle);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

And the mytitle xml is:

 <?xml version="1.0" encoding="utf-8"?>
  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:background="#FFFFF0" >

<ImageView
    android:id="@+id/mytitle"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:scaleType="fitXY"
    android:src="@drawable/header_bloodbank2" />

</LinearLayout>

The header in my app doesn't fit well to its dimensions.I've used 'fill_parent' for both width and height attributes. Still, no help. The header doesn't wrap fully. What may be the reason behind it ? Help me out! Also attached a snapshot!

Chetna
  • 165
  • 1
  • 6
  • 15

2 Answers2

0

From what I can make of your question is that you are trying to use a custom titlebar background Image, which in this case is the "I donate" image".

The only reason I can think of for your image width not being wrapped is that the image is not that wide.(Also, i guess you are using 9png). Now to correct it just move your image to lower density folder. For eg. if your image is in drawable-hdpi then move it from there to drawable-mdpi folder.

Also change your imageview in xml as follows:

<ImageView
android:id="@+id/mytitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="centerInside"
android:src="@drawable/header_bloodbank2" />
vKashyap
  • 580
  • 6
  • 17
  • For help check [this](http://stackoverflow.com/questions/2665507/custom-title-bar-without-padding-android) too. – vKashyap Jun 12 '12 at 10:54
  • I tried what you said, but it doesn't help. since "centerInside" moves the overall header i.e., the image along with the text to the center. – Chetna Jun 12 '12 at 11:25
  • And yes this link seems helpful. I'll see if it works. thanks! – Chetna Jun 12 '12 at 11:30
0

Your code

<ImageView
android:id="@+id/mytitle"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY"
android:src="@drawable/header_bloodbank2" />

should work. Check whether your image doesn't have any transparent border around it.Some times .png images have transparent border which prevent images to fill full width and height.

Vipul Purohit
  • 9,807
  • 6
  • 53
  • 76