在控件的任意位置显示图片

简介: 在控件的任意位置显示图片效果图xml代码 说明在控件的下方显示...

在控件的任意位置显示图片

  • 效果图

p3

  • xml代码
<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"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity">

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:drawableLeft="@mipmap/ic_launcher"
        android:text="按钮1" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/button"
        android:drawableRight="@mipmap/ic_launcher"
        android:text="按钮2" />

    <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/button2"
        android:drawableTop="@mipmap/ic_launcher"
        android:text="按钮3" />

    <Button
        android:id="@+id/button4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/button3"
        android:drawableBottom="@mipmap/ic_launcher"
        android:text="按钮4" />

    <Button
        android:id="@+id/button5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/button4"
        android:drawableLeft="@mipmap/ic_launcher"
        android:drawablePadding="50dp"
        android:text="按钮5" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:drawableLeft="@mipmap/ic_launcher"
        android:text="Text的文字" />

    <EditText
        android:id="@+id/editText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/textView2"
        android:drawableRight="@mipmap/ic_launcher"
        android:text="EditText内容" />

    <RadioButton
        android:id="@+id/radioButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/editText"
        android:drawableTop="@mipmap/ic_launcher"
        android:text="RadioButton内容" />
</RelativeLayout>

说明

  • 在控件的下方显示一张图片
    android:drawableBottom
  • 在控件的左边显示一张图片
    android:drawableLeft
  • 在控件的右边显示一张图片
    android:drawableRight
  • 在控件的上方显示一张图片
    android:drawableTop
  • 设置文字与图片的间距,是与drawableLeft、 drawableRight、drawableTop、drawableBottom一起使用。
    android:drawablePadding
相关文章
|
Java Nacos
SpringBoot 整合 Nacos
上一篇笔者已经介绍怎么安装 Nacos 了,这篇就开始重头戏。 搭建SpringBoot项目。
2720 1
|
虚拟化 KVM Linux
带你读《KVM实战:原理、进阶与性能调优》之二:KVM原理简介
本书兼具实战性、系统性又不乏深度的KVM虚拟化技术指南,既能让新人快速掌握KVM的基础知识,又能满足有经验的读者进阶学习的需求。本书两位作者来自于阿里云和Intel,在云计算和KVM方面有深入的研究,他们将自己的经验倾囊相授,带你全面了解KVM的各种技术细节。
|
10月前
|
缓存 算法 物联网
【论文专辑】2024年大模型推理优化论文精选第六期
本文整理了 OSDI 2024 和 SOSP 2024 中与大语言模型(LLM)推理优化相关的10篇论文,涵盖 Parrot、ServerlessLLM、dLoRA 等系统,提出的技术如 Chunked Prefill、Prefix-Caching、P/D分离等已被 vLLM 和 TensorRT-LLM 等主流推理引擎采用。这些研究解决了 LLM 推理中的冷启动延迟、资源分配、KV 缓存管理等问题,提升了推理性能和资源利用率。CodeFuse推理优化项目地址https://github.com/codefuse-ai/EasyDeploy
1238 2
|
11月前
|
存储 Go 索引
go语言中数组和切片
go语言中数组和切片
274 7
|
供应链 分布式数据库 区块链
区块链技术原理及其应用探索
区块链技术原理及其应用探索
284 2
|
监控 安全 数据处理
淘宝 1688 跨境电商官方接口接入全攻略,跨境卖家必知
本攻略详述了接入1688跨境电商官方接口的全过程,涵盖注册申请、开发调试、数据处理与业务集成、安全合规及上线维护等环节,帮助开发者高效对接1688,拓展跨境业务。
1254 0
|
机器学习/深度学习 人工智能 安全
AI在灾害管理中的作用:提高防灾减灾能力
【10月更文挑战第8天】AI技术在灾害管理中的应用正在逐步改变我们对灾害的应对方式。通过发挥AI的优势,我们可以更有效地预防、减轻和应对自然灾害带来的挑战,为构建安全、弹性的社会做出更大贡献。
|
Kubernetes 负载均衡 Cloud Native
从零开始入门 K8s | 理解 CNI 和 CNI 插件
网络架构是 K8s 中较为复杂的方面之一。K8s 网络模型本身对某些特定的网络功能有着一定的要求,因此,业界已经有了不少的网络方案来满足特定的环境和要求。CNI 意为容器网络的 API 接口,为了让用户在容器创建或销毁时都能够更容易地配置容器网络。在本文中,作者将带领大家理解典型网络插件地工作原理、掌握 CNI 插件的使用。
从零开始入门 K8s | 理解 CNI 和 CNI 插件
|
机器学习/深度学习 文字识别 Python
【OCR学习笔记】5、OCR传统特征提取方法(文末附python源码实现下载)(二)
【OCR学习笔记】5、OCR传统特征提取方法(文末附python源码实现下载)(二)
545 0
|
存储 NoSQL Java
阿里云短信服务接入和购买流程
很多用户不知道怎么接入短信,那么接下来就有小编跟大家讲解一下吧
4429 0
阿里云短信服务接入和购买流程