は私が働くかもしれないと思うものです:
次の値が必要になります。
赤、緑、青、アルファとコントラスト(R、G、B、C)
をスライダーを使用した後に優先して
ストアそれら:
private SharedPreferences pref;
//In onCreate..
this.pref = getSharedPreferences("pref", 0);
//Method to save the values in Preferences
private void save()
{
SharedPreferences.Editor localEditor = this.pref.edit();
localEditor.putInt("a", this.a);
localEditor.putInt("r", this.r);
localEditor.putInt("g", this.g);
localEditor.putInt("b", this.b);
localEditor.putInt("c", this.c);
localEditor.commit();
}
はレイヤーCLASの定義ビューを拡張し、適用された値をキャンバスに描画するために使用されます。
import android.view.View;
import android.graphics.Canvas;
import android.content.Context;
public class Layer extends View
{
private int a;
private int b;
private int g;
private int r;
public Layer(Context context){
super(context)
}
protected void onDraw(Canvas canvas){
super.onDraw(canvas);
canvas.drawARGB(this.a, this.r, this.g, this.b);
}
public void setColor(int a, int r, int g, int b){
this.a = a;
this.r = r;
this.g = g;
this.b = b;
invalidate();
}
}
これらの値の変更を処理し、それらをウィンドウに適用するサービスを作成します。
public class ScreenAdjustService extends Service
{
//Handle everything here
}
//環境設定 プライベート静的レイヤビューに格納された値を適用するためのビューを宣言します。 ... パブリックstatic int r; パブリックstatic int b; public static int g; パブリックstatic int a; public static int c; onCreateメソッドで
、
以前の好みに格納された値、取得した値を設定するための
SharedPreferences localSharedPreferences = getSharedPreferences("pref", 0);
a = localSharedPreferences.getInt("a", 0);
r = localSharedPreferences.getInt("r", 0);
g = localSharedPreferences.getInt("g", 0);
b = localSharedPreferences.getInt("b", 0);
c = localSharedPreferences.getInt("c", 0);
セットビュー、
view = new Layer(this);
redView = new Layer(this);
...
が窓
にこれらのビューを追加取得
//Pass the necessary values for localLayoutParams
WindowManager.LayoutParams localLayoutParams = new WindowManager.LayoutParams(...);
WindowManager localWindowManager = (WindowManager)getSystemService("window");
localWindowManager.addView(view, localLayoutParams);
localWindowManager.addView(redView, localLayoutParams);
localWindowManager.addView(greenView, localLayoutParams);
私は
ScreenAdjustService.setRGB(MyActivity.this.r, MyActivity.this.g, MyActivity.this.b);
ScreenAdjustService.setAlpha(MyActivity.this.a);
ScreenAdjustService.setContrast(MyActivity.this.c);
マニフェストXMLファイルにあなたのサービスを宣言することを忘れないでください
<service android:name=".ScreenAdjustService " />
サービスクラスをかもしれません使用してどこに必要な
は、再利用可能な方法
public static void setAlpha(int alpha){
//Handle all conditions
view.setColor(alpha, 0, 0, 0);
}
public static void setContrast(int contrast){
//Handle all conditions
view.setColor(c, 100, 100, 100);
}
public static void setRGB(int r, int g, int b){
//Handle all conditions
redView.setColor(r, 255, 0, 0);
greenView.setColor(g, 0, 255, 0);
blueView.setColor(b, 0, 0, 255);
}
コールこれらのメソッドを書きます私はこれを飛行機でやったのと同じことを2回も逃してしまったのですが、これがそうするべきだと私は考えています。
また、ビューに常にフラグを追加する必要があります。 – tomwesolowski
だから、このアプローチでは、このオーバーレイされたアクティビティは、オーバーラップしたアクティビティにタッチイベントをどのように渡しますか? – Paras