Skip to content

Instantly share code, notes, and snippets.

@Runly
Runly / 自定义Dialog设置宽度
Created February 24, 2017 09:02
自定义Dialog设置宽度
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.layout_comment_dialog, null);
this.setContentView(layout);
Window dialog_window = this.getWindow();
if (dialog_window != null) {
@Runly
Runly / 自定义Dialog设置宽度
Created February 24, 2017 09:02
自定义Dialog设置宽度
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.layout_comment_dialog, null);
this.setContentView(layout);
Window dialog_window = this.getWindow();
if (dialog_window != null) {
@Runly
Runly / 手动弹出键盘
Created February 24, 2017 08:19
手动弹出键盘
edittext.requestFocus(); // 没有这一句不会弹出,至少我遇到的情况是这样
InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);
@Runly
Runly / 判断软键盘是否弹出
Last active March 22, 2017 07:27
判断软键盘是否弹出
public interface OnSoftKeyBoardShowListener {
void hasShow(boolean isShow);
}
/**
* 判断软键盘是否弹出
*/
private class MyOnGlobalLayoutListener implements ViewTreeObserver.OnGlobalLayoutListener {
private OnSoftKeyBoardShowListener listener;
private View rootView;
@Runly
Runly / RecyclerView 定制item 分割线
Created February 17, 2017 15:25
RecyclerView 定制item 分割线
public class DividerItemDecoration extends RecyclerView.ItemDecoration {
/*
* RecyclerView的布局方向,默认先赋值
* 为纵向布局
* RecyclerView 布局可横向,也可纵向
* 横向和纵向对应的分割想画法不一样
* */
private int mOrientation = LinearLayoutManager.VERTICAL;
@Runly
Runly / 修改TabLayout Indicator的宽度
Last active June 7, 2018 11:32
change TabLayout Indicator width 修改TabLayout Indicator的宽度
/**
* 通过反射修改TabLayout Indicator的宽度(仅在Android 4.2及以上生效)
*/
private void setUpIndicatorWidth(TabLayout tabLayout) {
Class<?> tabLayoutClass = tabLayout.getClass();
Field tabStrip = null;
try {
tabStrip = tabLayoutClass.getDeclaredField("mTabStrip");
tabStrip.setAccessible(true);
} catch (NoSuchFieldException e) {
//回滚到顶部
public void scrollToTop() {
if (null != adapter && adapter.getCount() > 0 && null != listView) {
//强制停止ListView滚动
listView.dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_CANCEL, 0, 0, 0));
//如果item过多,则先停在某一项上
if (listView.getFirstVisiblePosition() > 8)
listView.setSelection(8);
*.gslbsvc.net.cn;
*.chinacache.com.cn;
*.ccgslb.net;
*.gslbsvc.com.cn;
*.cdnsvc.cn;
*.ccgslb.cn;
*.cdn2cdn.net;
*.blueit.org.cn;
*.cc-1.com;
*.cdnsvc.net;