I have a Dialog where I set the layout to a custom layout I created. What I'm trying to do is make the background image (in this case the ImageView) crop to just what is needed to cover the space of the content of the TextView. This is how it looks now:
But what I need is for the background image to be cut off after the "content" line of the TextView. I'm not sure of a way to do this. The only way I found was to hardcode the RelativeLayout height (i.e. 200dp) but the TextView's content will be dynamic and will grow/shrink so this isn't an solution for me. Any ideas? Thanks
Here is the XML for this layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:src="@drawable/blue9" >
</ImageView>
<TextView
android:id="@+id/tvMessage"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tvTitle"
android:layout_marginTop="5dp"
android:gravity="center"
android:textColor="#FFF"
android:text="This \n is \n my \n content"
android:textSize="20sp" />
</RelativeLayout>
Also, the same effect happens when I set the background of the RelativeLayout to the drawable. I was hoping the scaleType attribute on the ImageView would help.
Aucun commentaire:
Enregistrer un commentaire