After messing around, I finally got it work as expected. I felt I had
to share that with people.
<LinearLayout android:id="@+id/avatar_layout"
android:drawingCacheQuality="auto"
android:layout_width="70dip"
android:layout_height="70dip"
android:layout_gravity="top">
<ImageView android:id="@+id/img_avatar"
android:src="@drawable/question"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="centerCrop">
</ImageView>
</LinearLayout>
Ok this layout can be added in any layout and it should just work.
img_avatar can be anything.
After I manually change the background on the layout programmatically,
I have to do that : avatar_layout.setPadding(7, 7, 7, 7); on the
layout that wrap my ImageView. The padding can be whatever you want in
pixels. Apparently after the background is changed. The padding get
messed up. So manually editting the padding in the code actually fix
sizing problems. I don't if it's a bug or normal behavior. I believe
the right behavior should use the layout params unless changed by the
user. Changing the background shouldn't affect the layout. That's just
weird.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en