圖宛文翻譯

這個sample有support rendering fonts , 所以也要download 字型檔 Comic Neue.ttf 可以到以下url download Comic Neue.ttf (如果沒放入字型檔, app會crash) :

3. 可以到 https://www.lottiefiles.com/ 來下載想要的測試用json file, download下來的json檔要放在/assets目錄下

就以這個PR為例, 我們要先download Name.json到 /assets目次 翻譯公司 可到以下url 直接 control+s (Mac請用command+s)存檔

1. 在android studio裡點竄build.gradle加入以下這行, 把Lottie的SDK加進來:

    <com.airbnb.lottie.LottieAnimationView
        android:id="@+id/animation_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        app:lottie_fileName="progress_bar.json"
        app:lottie_loop="false"
        app:lottie_autoPlay="false" />

https://raw.githubusercontent.com/airbnb/lottie-android/fe5578b94bc3d997d3c9b4c20a647416642c8a75/LottieSample/src/main/assets/Name.json

在code裡插足成員變數:

https://medium.com/as-a-product-designer/%E5%BF%83%E5%BE%97%E5%88%86%E4%BA%AB-%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8lottie-%E5%B0%87%E5%AE%8C%E7%BE%8E%E5%8B%95%E7%95%AB100-%E5%91%88%E7%8F%BE%E5%9C%A8%E7%94%A2%E5%93%81%E4%B8%8A-7ac7107abfa5

https://github.com/airbnb/lottie-android/tree/fe5578b94bc3d997d3c9b4c20a647416642c8a75/LottieSample/src/main/assets/fonts

compile 'com.airbnb.android:lottie:2.1.0'

1. 在code裡插足成員變數:

利用Airbnb 翻譯Lottie開辟Android App裡插手播放利用Adobe After Effect製作 翻譯動畫 翻譯公司 及動態點竄動畫裡的文字  ( Change Animation Text Dynamically )

animationView = (LottieAnimationView) contentView.findViewById(R.id.animation_view);
animationView.setAnimation("Name.json");
textDelegate = new TextDelegate(animationView);
animationView.setTextDelegate(textDelegate);
textDelegate.setText("NAME"。-> 翻譯社|,-> 翻譯公司|的-> 翻譯, "Frank");
如許就搞定了, 就可以看到"Frank"這個單字的動畫

假如沒有這行: textDelegate.setText("NAME", "Frank");

看到的就是default的單字NAME的動畫, 所以只要呼叫TextDelegate的setText這個Method就能夠動態 翻譯改變更畫裡的文字內容!

另外有一個在網路上的文件幾近都沒提到 翻譯問題 翻譯公司 就是After Effect在輸出有文字的動畫json檔時 翻譯公司 其實不會連同字型檔一起輸出,
是以會造成在playAnimation時出現找不到字型檔 翻譯exception, 是以在After Effect設計文字時, 要給文字設定一個字型 翻譯公司
我本身試過是設Roboto的字型, 然後去Google搜尋Roboto font(Google很佛心的免費供應這個字型), download下來的font file
可以存到 /assets/fonts 目次下
翻譯公司 這樣問題就解決了.

 

private TextDelegate textDelegate;

2.把 onCreateView 這個 Method 裡的code改成:

在看這篇文章前如果對Lottie沒有初步了解, 可以先參考我 翻譯正妹同事PattyDraw所寫的這編文章:

最後只要把以上的code做一下點竄:

2. 在畫面 翻譯layout ( 如:/res/layout/fragment_lottie.xml ) 加入 (紅字部分是要播放的動畫檔, 也能夠在程式碼裡撰寫):

download下來的font file可以存到 /assets/fonts 目次下

private LottieAnimationView animationView;
在 onCreateView 這個 Method 裡加入:
animationView = (LottieAnimationView) findViewById(R.id.animation_view);

animationView.setAnimation("progress_bar.json"); //檔案必須放在 assets的目次裡
animationView.playAnimation();
這樣就可以直接播放動畫了!
其其實網路上不輕易查到 翻譯資訊是Lottie可以動態插手或點竄動畫裡的文字內容 ( Change Animation Text Dynamically )
針對這個issue 翻譯公司 Google良多資料後, 最後 翻譯所有資料都指向這個PR (Add support for rendering fonts and dynamic text):

https://github.com/airbnb/lottie-android/pull/353/files



本文來自: http://blog.xuite.net/frankintaiwan/twblog/523765053
有關翻譯的問題歡迎諮詢天成翻譯社

arrow
arrow
    文章標籤
    翻譯社
    全站熱搜

    chavezk71hx 發表在 痞客邦 留言(0) 人氣()