Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 344
Rafael Oliveira Avatar asked Aug 08 '12 23:08

Rafael Oliveira


1 Answers

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.

like image 104
0gravity Avatar answered Sep 22 '22 04:09

0gravity