0

I'm working on a project which requires a textview view with a drawable on its right or an imageview right of the textview. the problem statement is that the image shoud always align to the the text at the center. If the text is single line then everything looks fine but when text is multiline text then the image stays center to the both the lines. I have tried multiple approaches including rich drawables and verticleimage span but none helped. in the image the first and second is what i am getting so far but the third one is the what it should be the expected result (even the first one is correct if its a single line text).enter image description here

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="@dimen/media_item_poster_width"
    android:layout_height="wrap_content"
    android:layout_marginEnd="@dimen/browse_media_button"
    android:background="@drawable/poster_overlay_selector"
    android:clickable="true"
    android:focusable="true"
    android:padding="@dimen/media_browser_item_padding">

<TextView
    android:id="@+id/view_all_number_tv"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/media_poster"
    android:layout_marginStart="@dimen/media_item_poster"
    android:layout_marginBottom="@dimen/media_item_poster"
    android:ellipsize="end"
    android:maxWidth="@dimen/browse_view_all_number_tv_max_width"
    android:maxLines="2"
    android:textColor="@color/anz_text_color_primary"
    android:textSize="@dimen/media_item_poster_view_all"
    app:mainResourcePkgName="@string/resource_pkg_name_global"
    tools:text="48 Titles" />

<ImageView
    android:id="@+id/view_all_arrow"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/ic_view_all_arrow"
    android:layout_alignBottom="@+id/media_poster"
    android:layout_marginBottom="@dimen/media_item_poster_view_all"
    android:layout_toEndOf="@+id/view_all_number_tv"
    android:layout_marginStart="@dimen/view_all_arrow_margin_start"
    android:layout_marginEnd="@dimen/media_item_poster_view"
    app:mainResourcePkgName="@string/resource_pkg_name_module"
    app:labelsResourcePkgName="@string/resource_pkg_name_global" />

</RelativeLayout>
user3426264
  • 1
  • 1
  • 1
  • Please add your code – Sai Jayant Jun 03 '19 at 06:53
  • If i understood correctly [This is what you want](https://stackoverflow.com/questions/7913987/how-to-insert-imageview-at-the-end-of-multiline-textview). – ADM Jun 03 '19 at 06:54
  • @ADM thank you fro a quick reply exactly what i needed what was asked in the question but none of the solution worked for me. the problem is Spannable is cutting or excluding the last character in those solutions e.g String = 123 Names; 123 Name plus if the text is ellipsized it doesnt show the image. 123Name... – user3426264 Jun 03 '19 at 22:34

0 Answers0