Created
November 25, 2022 18:02
-
-
Save ikhlaqmalik13/1dcb784e2c76ec7554d7822b9bdb60f2 to your computer and use it in GitHub Desktop.
Relative Layout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context=".splash.figures.RLLearningActivity"> | |
<include | |
android:id="@+id/l_rl_controls" | |
layout="@layout/learning_rl" /> | |
</LinearLayout> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<uses-permission android:name="android.permission.VIBRATE" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.akhteakh.akhteakh.splash.figures | |
import android.content.Context | |
import android.os.Build | |
import android.os.Bundle | |
import android.os.VibrationEffect | |
import android.os.Vibrator | |
import android.support.v7.app.AppCompatActivity | |
import android.widget.Toast | |
import com.akhteakh.akhteakh.databinding.ActivityRllearningBinding | |
class RLLearningActivity : AppCompatActivity() { | |
private lateinit var binding: ActivityRllearningBinding | |
private lateinit var vibrator: Vibrator | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
binding = ActivityRllearningBinding.inflate(layoutInflater) | |
setContentView(binding.root) | |
vibrator = getSystemService(Context.VIBRATOR_SERVICE) as Vibrator | |
binding.lRlControls.apply { | |
ibBottom.setOnClickListener { | |
makeToast("Bottom") | |
} | |
ibTop.setOnClickListener { | |
makeToast("Top") | |
} | |
ibLeft.setOnClickListener { | |
makeToast("Left") | |
} | |
ibRight.setOnClickListener { | |
makeToast("Right") | |
} | |
ibCenter.setOnClickListener { | |
makeToast("Center") | |
} | |
} | |
} | |
private fun makeToast(msg: String) { | |
vibrate() | |
Toast.makeText( | |
this@RLLearningActivity, | |
msg, | |
Toast.LENGTH_SHORT | |
).show() | |
} | |
private fun vibrate() { | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | |
vibrator.vibrate(VibrationEffect.createOneShot(500, VibrationEffect.DEFAULT_AMPLITUDE)); | |
} else { | |
vibrator.vibrate(500); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> | |
<RelativeLayout | |
android:layout_width="164dp" | |
android:layout_height="160dp" | |
android:layout_centerInParent="true"> | |
<ImageButton | |
android:visibility="invisible" | |
android:alpha="0" | |
android:elevation="8dp" | |
android:layout_margin="8dp" | |
android:backgroundTint="@color/white" | |
android:background="@drawable/bg_rounded_rect" | |
android:id="@+id/ib_center" | |
android:layout_width="50dp" | |
android:layout_height="50dp" | |
android:layout_centerInParent="true" /> | |
<ImageButton | |
android:id="@+id/ib_left" | |
android:layout_width="50dp" | |
android:layout_height="50dp" | |
android:layout_centerVertical="true" | |
android:layout_toStartOf="@id/ib_center" | |
android:background="#D32929" | |
android:src="@drawable/ic_baseline_keyboard_arrow_24" /> | |
<ImageButton | |
android:id="@+id/ib_right" | |
android:rotation="180" | |
android:layout_width="50dp" | |
android:layout_height="50dp" | |
android:layout_centerVertical="true" | |
android:layout_toEndOf="@id/ib_center" | |
android:background="#2D6FD1" | |
android:src="@drawable/ic_baseline_keyboard_arrow_24" /> | |
<ImageButton | |
android:id="@+id/ib_top" | |
android:layout_width="50dp" | |
android:layout_height="50dp" | |
android:layout_above="@id/ib_center" | |
android:layout_centerHorizontal="true" | |
android:background="#A37F24" | |
android:rotation="90" | |
android:src="@drawable/ic_baseline_keyboard_arrow_24" /> | |
<ImageButton | |
android:id="@+id/ib_bottom" | |
android:rotation="-90" | |
android:layout_width="50dp" | |
android:layout_height="50dp" | |
android:layout_below="@id/ib_center" | |
android:layout_centerHorizontal="true" | |
android:background="#7224A3" | |
android:src="@drawable/ic_baseline_keyboard_arrow_24" /> | |
</RelativeLayout> | |
</RelativeLayout> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment