I just wanted to set icon to the top and left corner of my TextView
.
This is my code and the output respectively:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Content"
android:drawableLeft="@drawable/icon" />
Output:
but I want to set my icon to the top and left like this one :
For this purpose you have to take the seperate imageView like this and in textview field you have to add one line code that android:layout_toRightOf="@+id/imageView": For better understanding see following code:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView"
android:background="@mipmap/ic_launcher"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/imageView"
android:text="this si fodfjkhsdhaffjsdfasdfjhsdfhjsdhfjhsdfhsdhfhdsjfhsdjhfjhdsfhsdhfjhsdjhfjsdhfjhsdjfhjsdhfjhsdjfhjdshfsdjhfjsdhfsdkjhfjsdhfjhsdjfhjsdhjfhsdjhfjsdhfjhjsdhfjsdhjfhsdjf"
/>
</RelativeLayout>