2016-10-21 3 views
0

私はどこでも探していて、私は答えを見つけることができません。私のアプリに色合いフィルタを作成するには?

私のandriodアプリの画面上に色合いをつける方法を知りたいので、上にスワイプするとレイヤーをスワイプするようになります。

たとえば、アプリを開くとアプリのホーム画面に透明なグレーの画面が表示され、スワイプすることができます。

私はこれがひどく説明されていることを知っているので、尋ねるとわかりやすくなります。私はandriodアプリのためにVisual StudioとxamarinとC#を使用しています。どうもありがとう :)。助言が役に立ちます

答えて

0

あなたのページに絶対レイアウトを使用してください。画面全体をカバーする背景色を持つすべての子供の半透明ボックスの上に追加します。ジェスチャー認識機能を実装して、浮動検出を検出します。検出されたときに画面からボックスをアニメーション化します。フォームを使用している場合、ジェスチャ認識ツールはそのボックスのカスタムレンダラになりますフォームの場合:

public class MyGestureListener : GestureDetector.SimpleOnGestureListener 
{ 
    OverlayBox box; 

    public void SetBox(OverlayBox box) 
    { 
     this.box = box; 
    } 
    public override bool OnFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) 
    { 
     Console.WriteLine($"OnFling velocityX={velocityX} velocityY={velocityY}"); 
     if (e2.RawY < e1.RawY) //add more constraints on X 
     { 
      Rectangle r = box.Bounds; 
      r.Top = - r.Height; 
      box.LayoutTo(r, 500); 
     } 
     //for fun 
     Task.Delay(1000).ContinueWith(_ => 
     { 
       Rectangle r1 = box.Bounds; 
       r1.Top = 0; 
       box.LayoutTo(r1, 500); 
     }); 
     return base.OnFling(e1, e2, velocityX, velocityY); 
    } 
} 


class OverlayBoxRenderer : ViewRenderer<OverlayBox, Android.Views.View> 
{ 
    private readonly GestureDetector _detector; 
    private readonly MyGestureListener _listener; 
    public OverlayBoxRenderer() 
    { 
     _listener = new MyGestureListener(); 
     _detector = new GestureDetector(_listener); 
    } 

    protected override void OnElementChanged(ElementChangedEventArgs<OverlayBox> e) 
    { 
     if (e.NewElement == null) 
     { 
      this.Touch -= HandleTouch; 
     } 

     if (e.OldElement == null) 
     { 
      _listener.SetBox(e.NewElement); 
      this.Touch += HandleTouch; 
     } 


    } 

    void HandleTouch(object sender, TouchEventArgs e) 
    { 
     _detector.OnTouchEvent(e.Event); 
    } 


} 
関連する問題