android - Android减小图像视图内图标的大小
问题描述
我在列表视图中有以下选项卡,这些选项卡在图像视图中使用图标 SVG:
我的问题是 SVG 图标非常大,我需要在不调整图像视图及其形状的情况下调整它的大小,我希望它是这样的:
这是我的代码:
circle_shape.xml
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<size
android:width="160dp"
android:height="160dp" />
</shape>
图像视图:
<ImageView
android:id="@+id/ivLearnsetType"
android:layout_width="36dp"
android:layout_height="29dp"
android:layout_marginBottom="25dp"
android:gravity="center"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="@string/placeholder"
android:textColor="@color/Black" />
爪哇:
Integer color = PokemonUtils.getColorForType().get(convertedType);
Drawable drawable = getContext().getDrawable(R.drawable.ic_bug_type_icon);
ivLearnsetType.setImageDrawable(drawable);
ivLearnsetType.setBackgroundResource(R.drawable.circle_shape);
GradientDrawable ivDrawable = (GradientDrawable) ivLearnsetType.getBackground();
ivDrawable.setColor(color);
解决方案
在 Imageview 中使用 android:scaleType="centerInside"
推荐阅读
- java - XWPFDocument : 用 html 文本替换标签
- python - 如何将传感器数据列表 (.txt) 中的拆分结果输入到变量中
- reactjs - 材质 ui 锚无钩
- r - 如何修复 UseMethod("filter_") 中的 dplyr filter() 错误
- c# - 发送到 c# 模式的数据,并且数据未填充到 xml 输出中
- autotools - buildroot 使用 autotools 从 github 添加包
- r - 如何正确访问嵌套 R 列表中的项目?
- python - 如何使用 Python 从带有身份验证密钥的 URL 下载 JSON 文件
- swift - 如何解决firebase的异步问题
- javascript - 完成Ajax后,变量Js无法在href标签中呈现