I need to include a header graphic in all of my activities/views. The file with the header is called header.xml:
You need to provide shape around imageview to give a better look.
Here what i have used:
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<!--<gradient android:startColor="#FFFFFF" android:endColor="#969696"
android:angle="270">
-->
<gradient android:startColor="#FFFFFF" android:endColor="#FFFFFF"
android:angle="270">
</gradient>
<stroke android:width="2dp" android:color="@color/graycolor" />
<corners android:radius="2dp" />
<padding android:left="5dp" android:top="5dp" android:right="5dp"
android:bottom="5dp" />
use this android:scaleType="fitXY" in imageview xml
those extra padding is autogenerated since the android would try to get the original aspect ratio. please try below
scaletype = "fitCenter"
android:adjustViewBounds="true"
android:layout_height="wrap_content"
android:layout_height="wrap_content"
You need to change it to "fill_parent"
You also might need to scale your image so it will be the right ratio to fill the framelayout it is in.
I don't understand why you need the frame layout there at all. Without it, your image would just fill the screen anyways.
EDIT: yes, sorry, the xml is the height for the imageview.
android:scaleType="fitXY"
It works for me.
finally!
<ImageView
(...)
android:adjustViewBounds="true" />
the adjustViewbounds attribute did the trick:
Set this to true if you want the ImageView to adjust its bounds to preserve the aspect ratio of its drawable.
i stumbled upon it here. thanks for your help!