由网友(颗颗繁星,唯有你最美)分享简介:这个问题很简单,但我没有找到一无所知。如何设置保证金成widget在code-落后。我发现这个文件到 Xamarin的网站,但我不能用这个进入的ImageView 我也试过在我的ImageView的方法布局(),但没有奏效。 ImageView的imgView = FindViewById< ImageView...![paintcode怎么使用 paintcode使用教程](https://p.xsw88.cn/allimgs/daicuo/20230907/4619.png)
这个问题很简单,但我没有找到一无所知。如何设置保证金成widget在code-落后。
我发现这个文件到 Xamarin的网站,但我不能用这个进入的ImageView
我也试过在我的ImageView的方法布局(),但没有奏效。
ImageView的imgView = FindViewById< ImageView的>(Resource.Id.imageView); imgView.Layout(10,10,10,10);
解决方案
您是否尝试过使用的FrameLayout的的LayoutParams?
![paintcode怎么使用 paintcode使用教程](https://p.xsw88.cn/allimgs/daicuo/20230907/4619.png)
下面是一个例子:
您的图像:
ImageView的imgView = FindViewById< ImageView的>(Resource.Id.imageView);
您图像的参数:
FrameLayout.LayoutParams imgViewParams =新FrameLayout.LayoutParams(FrameLayout.LayoutParams.WrapContent,FrameLayout.LayoutParams.WrapContent,0.0);imgViewParams.SetMargins(10,10,10,10);
设置图片的参数:
imgView.LayoutParameters = imgViewParams;
编辑:改变的LinearLayout .LayoutParameters为的FrameLayout .LayoutParameters
this question is simple, but i'm not finding nothing about it. How can i set margin into a widget in code-behind.
I found this document into Xamarin's site, but i can't use this into a ImageView
I also tried the method Layout() in my ImageView, but it didn't work.
ImageView imgView = FindViewById<ImageView>(Resource.Id.imageView);
imgView.Layout(10, 10, 10, 10);
解决方案
Have you tried using FrameLayout's LayoutParams?
Here is an example:
Your image:
ImageView imgView = FindViewById<ImageView>(Resource.Id.imageView);
Your image's parameters:
FrameLayout.LayoutParams imgViewParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WrapContent, FrameLayout.LayoutParams.WrapContent, 0.0f);
imgViewParams.SetMargins(10, 10, 10, 10);
Setting your image's parameters:
imgView.LayoutParameters = imgViewParams;
EDIT: Changed LinearLayout.LayoutParameters to FrameLayout.LayoutParameters!
相关推荐
最新文章