[英]how to change a drawableL icon size on a TextView?
hello everybady I want to use image in TextView but I can not change the size of image大家好,我想在 TextView 中使用图像,但我无法更改图像的大小
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="person"
android:textSize="16dp"
android:drawableStart="@drawable/person"
></TextView>
Wrap your resource in a drawable as follows and use its text view.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:drawable="@drawable/icon"
android:width="icon_width"
android:height="icon_height"
/>
</layer-list >
Solution 1:解决方案1:
Make use of Vector image.使用矢量图像。 Seems from your question that you want to show an icon to your textview.
从你的问题看来,你想在你的文本视图中显示一个图标。
In that case:在这种情况下:
right-click on drawable folder -> new -> vector image -> click on the input space -> select the person image that you want (person) -> OK.右键单击drawable文件夹->新建->矢量图像->点击输入空间->选择你想要的人物图像(人物)->确定。
now, once that vector is created, use it in your textview like:现在,一旦创建了该向量,请在您的 textview 中使用它,例如:
android:drawableStart="@android/person_black"
Solution 2:解决方案2:
right-click on res -> drawable -> size.xml右键单击 res -> drawable -> size.xml
size.xml:大小.xml:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:drawable="@drawable/person"
android:width="your_desired_size_value in dp"
android:height="your_desired_size_value in dp"
/>
</layer-list >
Then, in your layout add:然后,在您的布局中添加:
android:drawableStart="@drawable/size"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.