Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

How to get ActionBar Height only when ActionBar is in view ?

$
0
0

Hi All,

In my Xamarin Forms Android application I needs to get ActionBar Height , I have tried by using Resource ID, I got ActionBar Height, But In my case if ActionBar is not used in my app also I am getting same ActionBarHeight value since ActionBar height value is taken from Resource id. So now my requirement is I need to get ActionBarHeight only Action bar is in View

TypedValue tv = new TypedValue();
var actionBarHeight = 0;

if (XamarinExtensions.Context.Theme.ResolveAttribute(Xamarin.Forms.Platform.Android.Resource.Attribute.actionBarSize, tv, true))
{
actionBarHeight = TypedValue.ComplexToDimensionPixelSize(tv.Data, Resources.DisplayMetrics);
}

Can anyone help me to getting ActionBar Height only ActionBar is in View?

Also I have used IsShowing bool property of ActionBar to know the visible state of ActionBar , In this case in my NativeView class I tried to access the ActionBar by follwing code,
var actionBar = ((Activity)Context).ActionBar;
if (actionBar.IsShowing),
In this case actionBar is getting as Null Value.

Is there any approach was there to get the ActionBar or ActionBarHeight only when ActionBar comes to the view?


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>