如何放置复合绘上的文本视图左上角 [英] How to place Compound drawable on top left of Text View

查看:227
本文介绍了如何放置复合绘上的文本视图左上角的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以设置TextView的化合物,可绘制如下使用 drawableLeft setCompundDrawables 但是使用这个它唯一可以放置左/右/上提拉/ bottom.But我希望把可绘制仅在TextView中的左上角和右上角。
我怎样才能做到这一点?


解决方案

 <?XML版本=1.0编码=UTF-8&GT?;
<的RelativeLayout的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =FILL_PARENT>< ImageView的
    机器人:ID =@ + ID / imageView1
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT
    机器人:layout_alignParentLeft =真
    机器人:layout_alignParentTop =真
    机器人:SRC =@绘制/ ic_launcher/><的TextView
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT
    机器人:layout_toRightOf =@ + ID / imageView1
    机器人:文字=@字符串/文本/>


这将做到这一点。

We can set compound drawables for textview as below using drawableLeft or setCompundDrawables but using this its only possible to place the drawable on left / right / top / bottom.But i want to put drawables only at top-left and top-right of the Textview. How can i do that ?

解决方案

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

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:src="@drawable/ic_launcher" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@+id/imageView1"
    android:text="@string/text" />

This would do it.

这篇关于如何放置复合绘上的文本视图左上角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆