i need include header graphic in of activities/views. file header called header.xml:
<?xml version="1.0" encoding="utf-8"?> <framelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#0000ff" android:padding="0dip"> <imageview xmlns:android="http://schemas.android.com/apk/res/android" android:src="@drawable/header" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margin="0dip" android:layout_margintop="0dip" android:layout_marginbottom="0dip" android:padding="0dip" android:paddingtop="0dip" android:paddingbottom="0dip" android:layout_gravity="fill" android:background="#00ff00" /> </framelayout>
note android:background="#00ff00"
(green), it's visualisation purposes.
i include them views this:
<?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:orientation="vertical" style="@style/white_background"> <include layout="@layout/header" /> (...)
so, when try out, result looks left image, instead of should (right):
(1) - orange - part image/imageview in question
(2) unloved green border. note: normally, green area transparent - it's green because set background
.
note green border around image @ top; it's part of imageview , can't figure out why there or how can rid of it. set paddings , margins 0 (but result same when omit them) . image 480x64px jpeg* , put in res/drawable (not in 1 of drawable-xdpi
though).
(* jpeg, because seems stumbled upon old png gamma problem - @ first worked around problem making green border same orange picture, , colors didn't match.)
i tried on htc desire/2.2/build 2.33.163.1 , on emulator. described problem in #android-dev; reproduce problem had no explanation either. build target 1.6.
update @tehgoose: code yields exact same top+bottom padded result.
<?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:orientation="vertical" style="@style/white_background"> <!-- <include layout="@layout/header" /> --> <imageview android:src="@drawable/header" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#00ff00" android:layout_weight="0" /> <linearlayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="8dip" android:layout_weight="1"> (... rest of elements) </linearlayout> </linearlayout>
finally!
<imageview (...) android:adjustviewbounds="true" />
the adjustviewbounds attribute did trick:
set true if want imageview adjust bounds preserve aspect ratio of drawable.
i stumbled upon here. help!
Comments
Post a Comment