0

I have a problem and was wondering if anyone here could help!

I'm working on an app and I want the UI to change depending on screen size. For example:

    if (heightInPixels == 1000)
    {
        ProgressBar.LayoutParameters.Width = 292; 
        ProgressBar.LayoutParameters.Height = 292;
    }

This works fine and changes the progress bar dimensions. However, I can't seem to find a way to change an EXISTINGmarginBottom property. This property is inside a RelativeLayout and I can only find solutions for LinearLayout.

I have a RelativeLayout called RelativeLayoutHeader and I've tried several things that I read here so far, like:

RelativeLayoutHeader.Bottom = 15 //don't know what happens, nothing apparently

RelativeLayoutHeader.layoutParams.addRule(...) //layoutParams does not contain a def for...)

FrameLayout.LayoutParams imgViewParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WrapContent, FrameLayout.LayoutParams.WrapContent, 0.0f);
    imgViewParams.SetMargins(10, 10, 10, 10); //does not work because i have a coordinatorLayout.

I'm new to Xamarin, sorry if I didn't explain my problem correctly. Thanks in advance and have a nice day.

HZegre
  • 1
  • 1
  • The usual way to change the UI for different screen sizes is to use different layout files in a folder structure: e.g. https://stackoverflow.com/a/20765267/4456875 For details see: https://developer.xamarin.com/guides/android/application_fundamentals/resources_in_android/part_4_-_creating_resources_for_varying_screens/ – Jonathan Twite Jul 12 '17 at 10:03
  • Your layout is `RelativeLayout`, but you used `FrameLayout.LayoutParams`, try to change it to `RelativeLayout.LayoutParams`. – panda Jul 13 '17 at 02:49

0 Answers0