简体   繁体   English

如何将drawable放在android java上的textView中间

[英]How to put drawable in the middle of textView on android java

I can't find information on how to draw image in the middle of texview using drawable.我找不到有关如何使用 drawable 在 texview 中间绘制图像的信息。 Below Images on how the app looks like atht he moment下面的图片显示了该应用程序的外观

骑士不在中间 在此处输入图像描述

When the knight should be in the middle of box (textView).当骑士应该在盒子的中间时(textView)。 I have created my textviews dynamicly with loops so accessing XML file is not possible.我已经使用循环动态创建了我的文本视图,因此无法访问 XML 文件。 I am using textView.setCompoundDrawablesRelativeWithIntrinsicBounds(ic_horsey, 0, 0, 0 ) to draw the image.我正在使用textView.setCompoundDrawablesRelativeWithIntrinsicBounds(ic_horsey, 0, 0, 0 )来绘制图像。

TextView are not used to display Drawables. TextView不用于显示 Drawable。 You have to use an ImageView for that.为此,您必须使用ImageView

Regarding your screenshot, a LinearLayout containing a TextView for the letter and an ImageView for the chess piece will do the job to represent a chess cell关于您的屏幕截图,包含TextView的字母和ImageView的棋子的LinearLayout将完成代表国际象棋单元的工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从Uri中读取文本并放入textView中? Android Studio-Java - How to read text from Uri and put in textView? Android Studio - Java 在android中的textview中将vector drawable设置为side drawable - set vector drawable to side drawable in textview in android 如何根据Android的分辨率调整TextView的大小 - How to put a TextView resize depending on the resolution of Android 如何在Android中从Java创建可绘制对象? - How to create a drawable from Java in Android? 如何以编程方式修改可绘制角 Android Java - How to modify drawable corners programmatically Android Java 如何通过Java在Android中使用可绘制形状? - How to use a drawable shape in Android through Java? Android:在TextView中的复合可绘制图像上添加文本 - Android: adding text on compound drawable image in textview 如何使用Android在MultiLines中的TextView Android中放置长文本? - How to Put Long Text In TextView Android in MultiLines using Android ? 以编程方式在Android的imageView中间放置一个textView - Place a textView in the middle of imageView programatically android 如何使用java代码(不是xml)在Textview中将可绘制的左图标设计为圆形(使用setCompoundDrawablesWithIntrinsicBounds添加) - How to design drawable left icon as circular (added using setCompoundDrawablesWithIntrinsicBounds) in Textview using java code (not xml)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM