2014-09-03 63 views
2

我一直致力於在Xamarin應用中實現淡入淡出的操作欄和視差滾動到我的Android UI中。我需要擴展我的ScrollView,現在它被稱爲NotifyScrollView。我現在如何設計我的.axml文件。我不能只是寫在NotifyingScrollView我axml,如何在Android的Xamarin .axml中應用自定義視圖

namespace NightOut.UiComponents 
{ 
class NotifyingScrollView : ScrollView 
{ 
    public interface IOnScrollChangedListener 
    { 
     void OnScrollChanged(ScrollView who, int l, int t, int oldl, int oldt); 
    } 

    private IOnScrollChangedListener mOnScrollChangedListener { get; set; } 


    public NotifyingScrollView(Context context) : base(context) 
    { 

    } 

    public NotifyingScrollView(Context context, IAttributeSet attrs) : base(context, attrs) 
    { 

    } 

    public NotifyingScrollView(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle) 
    { 

    } 


    [Android.Runtime.Register("onScrollChanged", "(IIII)V", "GetOnScrollChanged_IIIIHandler")] 
    protected override void OnScrollChanged(int l, int t, int oldl, int oldt) 
    { 
     base.OnScrollChanged(l, t, oldl, oldt); 
     if (mOnScrollChangedListener != null) 
     { 
      mOnScrollChangedListener.OnScrollChanged(this, l, t, oldl, oldt); 
     } 
    } 

} 
} 

回答

6

通用示例:

namespace My.Namespace 
{ 
    class MyCustomView : View 
    { 
    } 
} 

處於.axml下列方式使用

<my.namespace.MyCustomView /> 

或者在具體的例子:

<nightout.uicomponents.NotifyingScrollView /> 

不介意case,namespace在.axml中是小寫,classname與C#聲明是一樣的。

相關問題