I had saw many ways to align a textview with an imageview, but I didn´t find how to make when the text is bigger than the image, and when you want that text occupy all the parent layout. My layout is this:
<RelativeLayout
android:id="@+id/accordion_toogle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">
<ImageView
android:id="@+id/accordion_image"
android:layout_width="@dimen/accor_img_wid"
android:layout_height="@dimen/accor_img_hei" />
<TextView
android:id="@+id/accordion_msg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/accordion_image"
android:paddingLeft="5dp"/>
</RelativeLayout>
In this case, assuming that the image occupy the half of the RelativeLayout, the accordion_msg continues to occupy the half of the relativeLayout once the imageView finish.
Do you understand me?? Have I expressed well?? Any suggestion??
Thank you.
EDIT
A picture to help what I try to do:
The pink square is the picture, the purple and white rectangles are where the text must to be, but until now, the purple is empty. The text only occupy the white square.
EDIT 2
I am trying what @Elltz says... but I cannot make what I want, I have this code:
draw.setBounds(0, 0, width, height); //width: 128 height: 172 in this case
textview.setCompoundDrawablesRelative(draw, null, null, null);
But no image is shown, I try other many things, like:
textview.setCompoundDrawablesRelative(null, draw, null, null);
And the image stays on the top of the text. Other diferent this I tried was:
textview.setCompoundDrawables(draw, null, null, null);
And the image is on the left... but it is vertically align at center, and top and bottom of image are blank (no text, no picture... no nothing). I try changing the parent to LinearLayout, using gravity left, gravity top, RelativeLayout...
Oooppsss!!! now the layout is this:
<RelativeLayout
android:id="@+id/accordion_toogle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone">
<TextView
android:id="@+id/accordion_msg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/accordion_image"
android:paddingLeft="5dp"/>
</RelativeLayout>
*The visibility gone on the parent is not important, I change it programmatically.
Thank you.