eclipse提示:This tag and its children can be replaced by one TextView/ and a compound drawable

2023-11-11 22:41

本文主要是介绍eclipse提示:This tag and its children can be replaced by one TextView/ and a compound drawable,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

今天在学习android开发的时候,写了这样的一段代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical" android:gravity="center"><ImageView android:id="@+id/imageview2"android:layout_width="wrap_content"android:layout_height="wrap_content"/><TextView android:id="@+id/textView2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:gravity="center"/>
</LinearLayout>

然后eclipse就报出提示:This tag and its children can be replaced by one <TextView/> and a compound drawable

 

最后查了一下资料发现:

有时候我们可能会用image+textview组合,但其实image是没必要的,textview提供了一个属性来给它设置image

如:通过 setCompoundDrawable 方法, 或者直接在xml中使用android:drawableLeft.、android:drawableRight等属性指定!

 

其他:

 

  • Set android:baselineAligned="false" on this element for better performance
    • 如果LinearLayout被用于嵌套的layout空间计算,它的android:baselineAligned属性应该设置成false,以加速layout计算
    • android:baselineAligned="false"
  • This LinearLayout layout or its RelativeLayout parent is useless;
    • 多余的Linearlayout或者RelativeLayout
    • 删除即可
  • Use a layout_height of 0dip instead of wrap_content for better   performance
    • 当在一个linearlayout布局中为一个控件设置weight属性时,这个组件会默认填充剩余空间
    • 去掉weight属性或者修改wrap_content为0dp
  • Buttons in button bars should be borderless
    • 原因未知
    • style="?android:attr/buttonBarButtonStyle"

 

 

资料摘自:http://www.tuicool.com/articles/YvMjEz  

      http://blog.csdn.net/feng88724/article/details/7638511

转载于:https://www.cnblogs.com/JamKong/p/5043554.html

这篇关于eclipse提示:This tag and its children can be replaced by one TextView/ and a compound drawable的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/393319

相关文章

Mybatis提示Tag name expected的问题及解决

《Mybatis提示Tagnameexpected的问题及解决》MyBatis是一个开源的Java持久层框架,用于将Java对象与数据库表进行映射,它提供了一种简单、灵活的方式来访问数据库,同时也... 目录概念说明MyBATis特点发现问题解决问题第一种方式第二种方式问题总结概念说明MyBatis(原名

Ubuntu 24.04 LTS怎么关闭 Ubuntu Pro 更新提示弹窗?

《Ubuntu24.04LTS怎么关闭UbuntuPro更新提示弹窗?》Ubuntu每次开机都会弹窗提示安全更新,设置里最多只能取消自动下载,自动更新,但无法做到直接让自动更新的弹窗不出现,... 如果你正在使用 Ubuntu 24.04 LTS,可能会注意到——在使用「软件更新器」或运行 APT 命令时,

提示:Decompiled.class file,bytecode version如何解决

《提示:Decompiled.classfile,bytecodeversion如何解决》在处理Decompiled.classfile和bytecodeversion问题时,通过修改Maven配... 目录问题原因总结问题1、提示:Decompiled .class file,China编程 bytecode

Ilya-AI分享的他在OpenAI学习到的15个提示工程技巧

Ilya(不是本人,claude AI)在社交媒体上分享了他在OpenAI学习到的15个Prompt撰写技巧。 以下是详细的内容: 提示精确化:在编写提示时,力求表达清晰准确。清楚地阐述任务需求和概念定义至关重要。例:不用"分析文本",而用"判断这段话的情感倾向:积极、消极还是中性"。 快速迭代:善于快速连续调整提示。熟练的提示工程师能够灵活地进行多轮优化。例:从"总结文章"到"用

jenkins 插件执行shell命令时,提示“Command not found”处理方法

首先提示找不到“Command not found,可能我们第一反应是查看目标机器是否已支持该命令,不过如果相信能找到这里来的朋友估计遇到的跟我一样,其实目标机器是没有问题的通过一些远程工具执行shell命令是可以执行。奇怪的就是通过jenkinsSSH插件无法执行,经一番折腾各种搜索发现是jenkins没有加载/etc/profile导致。 【解决办法】: 需要在jenkins调用shell脚

eclipse安装subversion(SVN)版本控制插件

陈科肇 查看插件更新站点 网址:http://subclipse.tigris.org/servlets/ProjectProcess?pageID=p4wYuA 网站截图: 根据自己的eclipse版本,选择需要的更新站点. 使用eclipse集成subservion插件 Help > Install New Software…> 等待下载安装插件…

Android set Tag, findViewWithTag使用

设置了tag为“principal”的view ImageView principal = (ImageView) findViewById(R.id.imagen_home_0);principal.setTag("principal"); 在其它地方获取,获取已经设置了tag为“principal”的view LayoutInflater inflater = LayoutInflate

我自己常用的eclipse 快捷键整理

---------------- 我自己改的快捷键: 复制当前行单下一行  ctrl alt n   --------------------- 自带快捷键: 快速定位到一行  CTRL+L 向上(下)移动选中的行:ALT+UP/DOWN ARROW 删除行(Delete Line):CTRL+D CTRL + 1也很有用     ----------

eclipse中相同变量显示变色设置

java文件的设置"Window"-"preferences"-"Java"-"Editor"-"Mark Occurrences"复选框勾选 js文件的设  置"Window"-"preferences"-"web"-"javascript"-"Mark Occurrences"复选框勾选 。

pytorch torch.nn.functional.one_hot函数介绍

torch.nn.functional.one_hot 是 PyTorch 中用于生成独热编码(one-hot encoding)张量的函数。独热编码是一种常用的编码方式,特别适用于分类任务或对离散的类别标签进行处理。该函数将整数张量的每个元素转换为一个独热向量。 函数签名 torch.nn.functional.one_hot(tensor, num_classes=-1) 参数 t