How to set height and width of compound drawable textview in xml?

android, compound-drawables, xml

Solution

You can try something like:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >


<TextView
    android:id="@+id/Home"
    android:layout_width="wrap_content"
    android:layout_height="50dp"
    android:layout_centerHorizontal="true"
    android:gravity="center"
    android:text="Something"
    android:textColor="#FFFFFF" />

<ImageView 
    android:src="@drawable/icon" 
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:layout_toLeftOf="@id/Home"/>

</RelativeLayout>

This way I think you would have more control of your image. Hope that helps.

Problem

I can't see any tag to set width Here I set textview height, if I set width it will not work properly. ``` <TextView android:id="@+id/nome" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:drawableLeft="@drawable/ic_launcher" android:height="50dp" /> ``` How can I set this in xml? Is it possible?

Original source

Related problems