gpt4 book ai didi

android - 如何将复合绘图放在 TextView 的左上角

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:47:53 27 4
gpt4 key购买 nike

我们可以使用 drawableLeft 为 textview 设置复合可绘制对象,如下所示或 setCompundDrawables但使用它只能将可绘制对象放置在左侧/右侧/顶部/底部。但我只想将可绘制对象放置在 Textview 的左上角和右上角。
我怎样才能做到这一点 ?

最佳答案

<?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" />

这样就可以了。

关于android - 如何将复合绘图放在 TextView 的左上角,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14726583/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com