Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
2.0 kB
0
Indexable
Never
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:gravity="center"
  android:orientation="vertical">

  <TextView
    android:id="@+id/mantra_text_view"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="ॐ ह्रीं श्रीं क्लीं ऐं ह्रीं श्रीं क्लीं सौः ऐं" />

  <Button
    android:id="@+id/toggle_rotation_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Toggle Rotation" />

  <com.example.sriyantra.SriYantraView
    android:id="@+id/sri_yantra_view"
    android:layout_width="200dp"
    android:layout_height="200dp" />

</LinearLayout>
MainActivity class (MainActivity.java):

java
Copy code
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    TextView mantraTextView = findViewById(R.id.mantra_text_view);
    mantraTextView.setText("ॐ ह्रीं श्रीं क्लीं ऐं ह्रीं श्रीं क्लीं सौः ऐं");

    SriYantraView sriYantraView = findViewById(R.id.sri_yantra_view);

    Button toggleRotationButton = findViewById(R.id.toggle_rotation_button);
    toggleRotationButton.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View view) {
        if (sriYantraView.isRotating()) {
          sriYantraView.stopRotation();
        } else {
          sriYantraView.startRotation();
        }
      }
    });
  }
}
``