Skip to content

Instantly share code, notes, and snippets.

View ajaymourya4's full-sized avatar

Ajay Mourya ajaymourya4

  • Bangalore
View GitHub Profile
@Zhuinden
Zhuinden / BasicTextFieldWithCursorAtEnd.kt
Last active April 11, 2024 11:19
A Compose TextField that initializes the cursor position at the end of the text, rather than the start, when focused without tapping the TextField manually.
/*
* Copyright 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@ichenhe
ichenhe / NestedScrollableHost.kt
Created October 12, 2020 07:26
Fix parallel scroll with a NestedScrollView inside a ViewPager2
/*
* Copyright 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@y-polek
y-polek / LiveDataExt.kt
Last active November 25, 2021 01:22
'map' and 'combineLatest' transformations for LiveData
import android.arch.lifecycle.LiveData
import android.arch.lifecycle.MediatorLiveData
import android.arch.lifecycle.MutableLiveData
fun <X, Y> LiveData<X>.map(func: (X?) -> Y?): MutableLiveData<Y?> {
return MediatorLiveData<Y>().apply {
addSource(this@map) { x -> value = func(x) }
}
}
@damianpetla
damianpetla / card_background.xml
Last active April 6, 2023 19:05
Android drawable used as background with shadows. Support elevation on API 21+
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<layer-list>
<!-- Drop Shadow Stack -->
<item>
<shape>
<padding
android:bottom="1dp"
@MarsVard
MarsVard / README
Last active November 3, 2022 19:19
android drawable to imitate google cards.
put card.xml in your drawables directory, put colors.xml in your values directory or add the colors to your colors.xml file.
set the background of a view to card,
as you can see in card.xml the drawable handles the card margin, so you don't have to add a margin to your view
``` xml
<View
android:layout_width="fill_parent"