亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

更改圓形顯示動畫的顏色

更改圓形顯示動畫的顏色

滄海一幻覺 2023-06-08 20:57:58
我向我的 fab 按鈕添加了圓形顯示動畫,但我不想將片段顏色更改為不同的顏色,而是想更改動畫的顏色,因為我希望我的下一個片段是白色背景。我試圖將片段顏色更改為不同于白色并再次變回白色,但它沒有用。那么有沒有辦法改變動畫的顏色,而不是片段的顏色?這是我的一些代碼:@Override    public View onCreateView(LayoutInflater inflater, ViewGroup container,                             Bundle savedInstanceState) {        // Inflate the layout for this fragment        final View rootView = inflater.inflate(R.layout.fragment_note_add, container, false);        rootView.addOnLayoutChangeListener(new View.OnLayoutChangeListener(){            @Override            public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom){                rootView.removeOnLayoutChangeListener(this);                rootView.setBackgroundColor(getArguments().getInt("color"));                int cx = getArguments().getInt("cx");                int cy = getArguments().getInt("cy");                int radius = (int) Math.hypot(right, bottom);                Animator reveal = ViewAnimationUtils.createCircularReveal(v, cx, cy, 0, radius);                reveal.setInterpolator(new DecelerateInterpolator(2f));                reveal.start();            }        });        return rootView;    }在這里,我再次嘗試將背景設為白色。 @Override    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {        //Initialize UI Elements        FloatingActionButton saveButton = view.findViewById(R.id.fab_add);        saveButton.setOnClickListener(saveButtonListener);        editText = view.findViewById(R.id.note_editor);        view.setBackgroundColor(getResources().getColor(R.color.white));        super.onViewCreated(view, savedInstanceState);    }
查看完整描述

1 回答

?
動漫人物

TA貢獻1815條經驗 獲得超10個贊

在這種情況下沒有“動畫顏色”這樣的東西。Circular Reveal 動畫,在引擎蓋下,將圓形裁剪蒙版應用于視圖并為裁剪值設置動畫以在視覺上表示“顯示”。您看到的顯示顏色是實際視圖本身。

如果我理解正確,您希望在顯示運行時在您的視圖中進行顏色轉換。如果是這種情況,請遵循以下步驟:

  • 聲明開始和結束顏色。

  • 將動畫偵聽器附加到圓形顯示動畫。

  • 在顯示動畫更新時,使用 ARGBevaluator 使用顯示動畫當前進度在開始和結束顏色之間進行評估。將此顏色值設置為視圖的背景。


查看完整回答
反對 回復 2023-06-08
  • 1 回答
  • 0 關注
  • 171 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號