Skip to content

Instantly share code, notes, and snippets.

@Overflow-Archives
Overflow-Archives / themes.xml
Created June 16, 2022 06:55
Android Splash Screen Implementation - Themes xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="SplashTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="android:windowBackground">@drawable/splash_background</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:statusBarColor">@color/colorAccent</item>
</style>
</resources>
@Overflow-Archives
Overflow-Archives / bg_gradient.xml
Created June 16, 2022 06:52
Android Splash Screen Implementation - Bg Gradient
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="<http://schemas.android.com/apk/res/android>"
android:shape="rectangle" >
<gradient
android:type="linear"
android:angle="135"
android:startColor="#ff1b49"
android:endColor="#e67d20" />
</shape>
<!--You can choose your own color -->
@Overflow-Archives
Overflow-Archives / bg_splashscreen.xml
Created June 16, 2022 03:43
Android Splash screen implementation - custom theme drawable
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="<http://schemas.android.com/apk/res/android>">
<item
android:drawable="@drawable/bg_gradient"/>
<item>
<bitmap android:gravity="center"
android:src="@drawable/app_logo"/>
</item>
</layer-list>
@Overflow-Archives
Overflow-Archives / AndroidSplashScreenHandler.kt
Created June 16, 2022 02:29
Android Splashscreen Implementation using Timer
class SplashScreenActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_splash_screen)
Handler().postDelayed(Runnable { //This method will be executed once the timer is over
// Start your app main activity
val i = Intent(this@SplashScreenActivity, MainActivity::class.java)
startActivity(i)
// close this activity
finish()
@Overflow-Archives
Overflow-Archives / android_searchview.kt
Created October 29, 2020 16:33
Android search view in toolbar. search view UI setup
searchView = (SearchView) findViewById(R.id.search);
EditText searchEditText = (EditText) searchView.findViewById(androidx.appcompat.R.id.search_src_text);
searchEditText.setTextColor(getResources().getColor(R.color.white));
searchEditText.setHintTextColor(getResources().getColor(R.color.white));
@Overflow-Archives
Overflow-Archives / android_searchview_style.xml
Created October 29, 2020 16:28
android_searchview_style
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="searchViewStyle">@style/SearchStyle</item>
</style>
<style name="SearchStyle" parent="Theme.AppCompat.Light.NoActionBar">
<item name="editTextColor">#FFFFFF</item>
@Overflow-Archives
Overflow-Archives / onBackpressed.kt
Created October 29, 2020 16:25
Android search view in toolbar. On back press implementation
override fun onBackPressed() {
if (!searchView.isIconified()) {
searchView.onActionViewCollapsed();
} else {
super.onBackPressed();
}
}
@Overflow-Archives
Overflow-Archives / android_searchview_oncreate.kt
Created October 29, 2020 16:15
Android search view in toolbar. oncreate implementation
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.search_menu, menu)
val searchItem: MenuItem = menu.findItem(R.id.action_search)
if (searchItem != null) {
searchView = MenuItemCompat.getActionView(searchItem) as SearchView
searchView.setOnCloseListener(object : SearchView.OnCloseListener {
override fun onClose(): Boolean {
return true
}
})
<menu 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"
tools:context=".ui.home.activities.TransactionSearchActivity">
<item
android:id="@+id/action_search"
android:icon="@android:drawable/ic_search"
android:title="Search"
app:actionViewClass="androidx.appcompat.widget.SearchView"
app:showAsAction="always" />