I have a MonoDroid application and I'd like to force all my Activities to be presented only in Portrait orientation.
I'd though about creating a an Activity base classe such as:
[Activity (ScreenOrientation = ScreenOrientation.Portrait)]
public abstract class BaseActivity : Activity
{
}
All other activities in my application should then inherit from it (too avoid repetition and have a central place for defining the ScreenOrientation = ScreenOrientation.Portrait
).
However, if you look at the ActivityAttribute
definition, looks like it does not support inheritance.
[Serializable]
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
public sealed class ActivityAttribute : Attribute { ... }
Activity (ScreenOrientation = ScreenOrientation.Portrait)
in ALL Activities of my application ?You need to put the attribute on each Activity. If you were creating a native Android application you would need to mark each Activity in the manifest with android:screenOrientation="portrait"
, using this attribute signals to Mono For Android to do the same.
Unfortunately the Attribute does not inherit as you noticed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With