Android - How to align an image center relative to the textview

I have an text view as show above and an info icon next to the text view. All is fine here but I wish to have the info icon aligned center to the textview. As of now it is aligned top right relative to the text view. I wish it to be aligned center right relative to the text view

The XML Layout file is below

        <RelativeLayout
             android:orientation="horizontal" 
             android:layout_width="fill_parent"
             android:layout_height="fill_parent"
              android:gravity="center"
            android:layout_gravity="center"
            > 

        <TextView               
            android:id="@+id/ViewMessageOne"                
            android:layout_width="275dp"
            android:layout_height="45dp"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#000000"
            android:textSize="14sp"
            android:typeface="sans" 
            android:background="@drawable/back"
            />   

         <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/banner_portrait"
            android:layout_toRightOf="@+id/ViewMessageOne"
            android:paddingLeft="10dp"
             android:gravity="center"               
           />


         </RelativeLayout>

Please point me in the right direction. Thanks for your help

Answers


Try:

android:layout_gravity="center_vertical|right"

EDIT:

You could also just change the height to match the TextView, as your ImageView gravity is set to center.

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="45dp"
    android:layout_toRightOf="@+id/ViewMessageOne"
    android:gravity="center"
    android:paddingLeft="10dp"
    android:src="@drawable/banner_portrait" />

Need Your Help

php css how to change name color based on membership?

php html css colors

i want to create member badges on evolutionscript forum

Ajax.ActionLink Cannot find Controller/Action using POST method

ajax asp.net-mvc-4 post actionlink

I'm going nuts trying to POST an ActionLink using the Ajax method. I've looked at similar problems and have tried it all. Asking for help here. Note the controller/action worked fine as a GET but m...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.