Reputation: 1963
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 ?Upvotes: 5
Views: 2707
Reputation: 7861
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.
Upvotes: 5