編集:上記の解決策を見てください
私はパニック状態だ。私がやりたいのは、グラデーションの垂直方向の中心を変更する線形GradientDrawableを設定することです...グラデーションの描画はうまくいきますが、どうすればその中心を変更できますか?!?
RelativeLayout bgScreen = (RelativeLayout) findViewById(R.id.player_screen);
GradientDrawable gd = new GradientDrawable(
GradientDrawable.Orientation.TOP_BOTTOM,
new int[] {startColor,endColor});
gd.setCornerRadius(0f);
gd.setAlpha(200);
bgScreen.setBackground(gd);
public void redrawOrChangeBackgroundGradient(){
//??? either change center of existing
gd.setGradientCenter(float x, float y) //ONLY works in RADIAL_GRADIENT or SWEEP_GRADIENT.
//??? or complete redraw Gradient with different center
}
ここで、コードを介してグラデーションを変更する方法の写真の例を示します
そんなに難しいことはありませんよね?