Tha*_*man 7 java android android-layout android-studio android-vectordrawable
这真让我抓狂.我希望能够以编程方式调整xml矢量可绘制图标的大小,以便在ImageView中使用它.
这是我到目前为止所做的不起作用的
Drawable drawable = ResourcesCompat.getDrawable(getResources(),R.drawable.ic_marker,null);
drawable.setBounds(0,0,512,512);
imageVenue.setImageDrawable(drawable);
Run Code Online (Sandbox Code Playgroud)
矢量图标ic_marker未调整大小.它只是每次都保持硬编码的宽度和高度值.
有任何想法吗?
您可以通过编程方式更改图像视图的宽度和高度。由于矢量绘图将保留图像的原始质量,这将使所需的输出发生。
ImageView iv = (ImageView) findViewById(R.id.imgview);
int width = 60;
int height = 60;
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(width,height);
iv.setLayoutParams(params);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6562 次 |
| 最近记录: |