এখানে MR শব্দটি হাটছে এমন একটি Lottie animation Jason দেওয়া হল:
﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏
{"duration": 2,"layers": [{"name": "MR","shapes": [{"path": {"d": "M 30 100 L 50 100 L 50 20 L 30 20 Z"},"fill": {"type": "solid","color": "#ffffff"}}],"animations": [{"name": "walk","frames": [{"duration": 0.1,"translation": {"x": 0,"y": 0}},{"duration": 0.1,"translation": {"x": 10,"y": 0}},{"duration": 0.1,"translation": {"x": 0,"y": 0}},{"duration": 0.1,"translation": {"x": -10,"y": 0}}]}]}]}
﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏
এই animation-টিতে, MR শব্দটি একটি বর্গক্ষেত্রের মধ্যে তৈরি করা হয়েছে। বর্গক্ষেত্রটি একটি "walk" নামক animation-এর মাধ্যমে ডানে-বামে হাঁটে। animation-টির প্রতিটি frame-এ, বর্গক্ষেত্রটির অবস্থান পরিবর্তিত হয়।
এই animation-টি আপনি নিচের কোডের মাধ্যমে আপনার অ্যাপের মধ্যে ব্যবহার করতে পারেন:
java
import com.airbnb.lottie.LottieAnimationView;public class MainActivity extends AppCompatActivity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);LottieAnimationView lottie1 = findViewById(R.id.lottie1);String json = "YOUR_JSON_STRING_HERE";lottie1.setAnimationFromJson(json);}}
এই কোডে, `json` ভেরিয়েবলের মধ্যে আপনি উপরে দেওয়া JSON স্ট্রিংসটি সংরক্ষণ করবেন। এরপর, `lottie1.setAnimationFromJson()` মেথডের মাধ্যমে animation-টি আপনার LottieAnimationView কন্ট্রোলে সেট করবেন।
উদাহরণস্বরূপ, যদি আপনার JSON স্ট্রিংসটি হল:
{"duration": 2,"layers": [{"name": "MR","shapes": [{"path": {"d": "M 30 100 L 50 100 L 50 20 L 30 20 Z"},"fill": {"type": "solid","color": "#ffffff"}}],"animations": [{"name": "walk","frames": [{"duration": 0.1,"translation": {"x": 0,"y": 0}},{"duration": 0.1,"translation": {"x": 10,"y": 0}},{"duration": 0.1,"translation": {"x": 0,"y": 0}},{"duration": 0.1,"translation": {"x": -10,"y": 0}}]}]}]
}
তাহলে, আপনি নিচের কোড ব্যবহার করতে পারেন:
java
﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏
নিচের Lottie animation Jason আপনি আপনার জাভা কোডে ব্যবহার করতে পারেন:
json
"_class": "AC_Sprite",
"_name": "MR",
"_parent": null,
"_children": [
{
"_class": "AC_Shape",
"_name": "MR",
"_parent": "MR",
"_children": [],
"_transform": {
"position": {
"x": 0,
"y": 0
},
"scale": {
"x": 1,
"y": 1
},
"rotation": 0
},
"_anchor": {
"x": 0.5,
"y": 0.5
},
"_shape": {
"type": "text",
"text": "MR",
"font": {
"family": "sans-serif",
"size": 100,
"weight": "bold"
},
"fill": {
"color": {
"r": 0,
"g": 0,
"b": 0,
"a": 1
}
}
},
"_path": "M0,0L0,100L100,100L100,0L0,0Z"
},
{
"_class": "AC_MotionPath",
"_name": "path",
"_parent": "MR",
"_children": [],
"_transform": {
"position": {
"x": 0,
"y": 0
},
"scale": {
"x": 1,
"y": 1
},
"rotation": 0
},
"_anchor": {
"x": 0.5,
"y": 0.5
},
"_points": [
{
"x": 0,
"y": 0
},
{
"x": 100,
"y": 0
},
{
"x": 100,
"y": 100
},
{
"x": 0,
"y": 100
},
{
"x": 0,
"y": 0
}
],
"_duration": 2,
"_repeatCount": 1
}
],
"_duration": 2,
"_repeatCount": 1
}
এই animation-টিতে, MR শব্দটি একটি সরলরেখা বরাবর বাম থেকে ডানে হাঁটছে। animation-টি 2 সেকেন্ড দীর্ঘ এবং 1 বার পুনরাবৃত্তি হবে।
আপনি এই animation-টিকে আপনার জাভা কোডে ব্যবহার করতে পারেন নিম্নলিখিতভাবে:
java
public class MainActivity {
LottieAnimationView lottie1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lottie1 = findViewById(R.id.lottie1);
// Load the animation from the JSON string
String json = "{...}";
lottie1.setAnimationFromJson(json);
// Play the animation
lottie1.playAnimation();
}
}
এই কোডটি lottie1 নামক একটি LottieAnimationView অবজেক্ট তৈরি করবে। আপনি lottie1.setAnimationFromJson() পদ্ধতি ব্যবহার করে animation-টিকে JSON string থেকে লোড করতে পারেন। তারপর, lottie1.playAnimation() পদ্ধতি ব্যবহার করে animation-টি চালাতে পারেন।
আপনি যদি animation-টিতে কোনো পরিবর্তন করতে চান, তাহলে আপনি JSON string-টিকে সম্পাদনা করতে পারেন।
No comments:
Post a Comment