随笔分类 - 方法记录
1
摘要:/** * date2比date1多的天数,只看天数,不看秒数 * * @param date1 * @param date2 * @return */ private static int calDateDistance(Date date1, Date date2) { Calendar cal
阅读全文
posted @ 2022-10-25 17:06
指切
摘要:android:elevation="10dp" //或 android:translationZ="10dp" View.setElevation(20); //或 View.setTranslationZ(20);
阅读全文
摘要:public interface UserConstant { /** * 性别 */ int GIRL = 0; int BOY = 1; } @Retention(RetentionPolicy.SOURCE) @Target({ElementType.PARAMETER}) @IntDef(v
阅读全文
摘要:private final ActivityResultLauncher<String> requestPermissionLauncher = registerForActivityResult(new ActivityResultContracts.RequestPermission(), re
阅读全文
摘要:int scaledTouchSlop = ViewConfiguration.get(getBaseContext()).getScaledTouchSlop()
阅读全文
摘要:/** * 将本地图片转换为 Drawable * @param context 上下文 * @param file 文件路径 * @return */ public static Drawable path2Drawable(Context context, String file) { if (
阅读全文
摘要:/** * 根据图片路径获取需要矫正的角度 * @param filepath 图片路径 * @return 需矫正的角度 */ public static int getExifOrientation(String filepath) { int degrees = 0; ExifInterfac
阅读全文
摘要://手指离开屏幕时还原 public static void addScaleTouch(View view) { view.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v
阅读全文
摘要:/** * 判断SD卡是否可用 * * @return true : 可用<br>false : 不可用 */ public static boolean isSDCardEnable() { return Environment.MEDIA_MOUNTED.equals(Environment.g
阅读全文
摘要:重写dispatchKeyEvent方法即可 @Override public boolean dispatchKeyEvent(KeyEvent event) { if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && isTiming) { retu
阅读全文
摘要:private boolean banClick; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); new Thread(new Runnable()
阅读全文
摘要:<androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/csl_target_select_clock_in_test" android:layout_width="0dp" android:layout_height=
阅读全文
摘要:Collections.sort(list); // 顺序排列 Collections.shuffle(list); // 打乱list Collections.reverse(list); // 倒序排列 System.out.println(Collections.binarySearch(li
阅读全文
摘要:去掉"MM.dd"格式的日期中的首位0 /** * 去掉"MM.dd"格式的日期中的首位0 * @param dateStr * @return */ public static String formatDateFirstBit(String dateStr) { String dateStr1
阅读全文
摘要:android:screenOrientation="portrait" unspecified 默认值,由系统决定,不同手机可能不一致 landscape 强制横屏显示 portrait 强制竖屏显示 behind 与前一个activity方向相同 sensor 根据物理传感器方向转动,用户90度
阅读全文
摘要:@(Android Studio 控件使用记录) TextView TextView 填充文本框 android:autoSizeMinTextSize="60sp" // 设置字体大小最小值 android:autoSizeMaxTextSize="60sp" // 设置字体大小最大值 andro
阅读全文
摘要:在 onCreate() 方法中添加如下java代码: // 透明状态栏 getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); // 透明导航栏 getWindow().addFlags(WindowMan
阅读全文
摘要:以成语List为例 private void changeOrderOnce(){ // 拿到数据 List<Idiom> idiomList = idiomModel.getIdiomList() // 第一次进入时打乱成语顺序 if (PreferenceUtil.getString("orde
阅读全文
摘要:String.split() String pronunciation = "zhī jǐn huí wén"; String[] pronunciationArray = pronunciation.split(" ");
阅读全文
摘要:app级build.gradle添加 // 加载图片 implementation 'com.github.bumptech.glide:glide:4.11.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0' //
阅读全文
1

浙公网安备 33010602011771号