Skip to content

Instantly share code, notes, and snippets.

View ramseth001's full-sized avatar

Sethuraman Srinivasan ramseth001

  • Sydney, Australia
View GitHub Profile
@ramseth001
ramseth001 / gist:8fccf313c2b9a987377a58542e1221d5
Created October 7, 2019 01:02
Disable keyboard on click outside edittext
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (getCurrentFocus() != null) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
}
}
return super.dispatchTouchEvent(ev);
}
@ramseth001
ramseth001 / gist:91bf2df655dc8ceea9fe8a6045f53ea5
Created June 19, 2019 05:34
Prevent white screen on app start up
<item name="android:windowDisablePreview">true</item>
<item name="android:windowIsTranslucent">true</item>
add this to app theme in style.xml
@ramseth001
ramseth001 / CustomTextView
Created August 29, 2018 02:29
Create TextView programmatically
/**
* This function customizes the header of the tab
*
* @param tabName Name of the tab
* @return TextView -> header of the tab
*/
private TextView getTabHeader(int tabName) {
TextView textView = new TextView(this);
textView.setText(tabName);
textView.setGravity(Gravity.CENTER);