I am unable to set the View Size
matching the Display Size
, below is the code, it is a Transparent View
TestView testView;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
testView = new TestView(this);
SetContentView(testView);
}
The Default Height
of the View
when the app runs is height=1206
but the Display Height is 1280
, i have used the following methods to set the View Size match the Screen Size, but none works
Does not work
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
testView = new TestView(this);
IWindowManager window = null;
window = this.Application.GetSystemService(Context.WindowService).JavaCast<IWindowManager>();
Display defaultDisplay = window.DefaultDisplay;
DisplayMetrics display = new DisplayMetrics();
defaultDisplay.GetRealMetrics(display);
int width = display.WidthPixels;
int height = display.HeightPixels;
RelativeLayout.LayoutParams parms = new
RelativeLayout.LayoutParams(width, height);
testView.LayoutParameters = parms;
SetContentView(testView);
}
Result:
Doesn not work:
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
testView = new TestView(this);
SetContentView(testView);
if (Build.VERSION.SdkInt >= BuildVersionCodes.Kitkat)
{
Window.SetFlags(WindowManagerFlags.LayoutNoLimits,
WindowManagerFlags.LayoutNoLimits);
}
}
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowTranslucentStatus">true</item>
Result:
How to set the Display height to the View?