Android: Setting Background Image for RelativeLayout?

前端 未结 4 1533
耶瑟儿~
耶瑟儿~ 2021-01-04 04:31

I have downloaded an image at runtime. Now I want to set it as a background for RelativeLayout. Does it possible?

4条回答
  •  Happy的楠姐
    2021-01-04 05:11

    Try this for Xamarin.Android (Cross Platform) -

    RelativeLayout relativeLayout = new RelativeLayout (this);
    

    OR

    RelativeLayout relativeLayout = (RelativeLayout)FindViewById (Resource.Id.relativeLayout);
    

    AND

    relativeLayout.SetBackgroundDrawable (Resources.GetDrawable (Resource.Drawable.imageName));
    

提交回复
热议问题