• Application
    android:largeHeap="true" //可以使用的最大内存值
    android:hardwareAccelerated="true" //启动硬件加速,(占用内存)
    android:process="com.github.obsessive.simplifyreader.application" //应用进程
  • Activity
    android:screenOrientation="portrait" //强制竖屏(只针对activity)
    android:exported="true"//在Activity中该属性用来标示:当前Activity是否可以被另一个Application的组件启动:true允许被启动;false不允许被启动。(四大组件都有这个属性)
杂记_第1张图片 接口变量 其他类点来使用
  • Dialog
    final ProgressDialog pd = new ProgressDialog(this);pd.setMessage("正在加载……");


    杂记_第2张图片 QQ截图20160721101538.png
  • 微信支付
    {
    "appid": "wxb4ba3c02aa476ea1",
    "partnerid": "1305176001",
    "package": "Sign=WXPay",
    "noncestr": "48edd9f9b36b4ce99d56d78cc8c4d732",
    "timestamp": 1469079916,
    "prepayid": "wx20160721134516aa8fb3752b0091952953",
    "sign": "8242B599E263849CDF63F52DEDA27FC3"
    }

  • 查看每个应用程序最高可用内存:(小米3==128M)
    int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
    Log.d("TAG", "Max memory is " + maxMemory + "KB");

  • 获取应用堆大小
    系统不可能将所有的内存都分配给我们的应用程序,每个程序都会有可使用的内存上限,被称为堆大小。不同的手机堆大小不同,结果以MB为单位进行返回,我们开发时应用程序的内存不能超过这个限制,否则会出现OOM。
    如下代码可以获得堆大小:
    ActivityManager manager = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
    int heapSize = manager.getMemoryClass();

  • 避免创建不必要的对象(越少的对象意味着越少的GC操作)
    1.如果有需要拼接的字符串,那么可以优先考虑使用StringBuffer或者StringBuilder来进行拼接,而不是加号连接符,因为使用加号连接符会创建多余的对象,拼接的字符串越长,加号连接符的性能越低。

  • 占位控件
    android:layout_width="match_parent"
    android:layout_height="64dp"/>

  • ImageView

    ![Uploading 多余_557291.png . . .]
    ImageView显示一张图片的时候,如果图片比例不对,你设置进去之后呢,周边会留有多余的空白,like this :

杂记_第3张图片 多余.png
添加属性 android:adjustViewBounds="true",结果如图:
杂记_第4张图片 之后.png

  • Activity打开动画
    ActivityOptionsCompat options = ActivityOptionsCompat
    .makeScaleUpAnimation(v, v.getWidth() / 2, v.getHeight() / 2, 0, 0);
    ActivityCompat.startActivity(this, intent, options.toBundle());

  • checkedTextView
    android:id="@+id/ctv_night_mode"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?attr/selectableItemBackgroundBorderless"
    android:checkMark="?android:attr/listChoiceIndicatorMultiple"
    android:checked="false"
    android:clickable="true"
    android:gravity="center_vertical"
    android:padding="16dp"
    android:tag="skin:secondary_text:textColor"
    android:text="开启夜间模式"
    android:textAppearance="@style/TextAppearance.AppCompat.Inverse"
    android:textColor="@color/secondary_text"
    android:textSize="14sp"/>

杂记_第5张图片 checkedTextView.png
  • ImageView
    imageView.setImageDrawable(ContextCompat.getDrawable(context, drawables[position]));

  • moveTaskToBack

此方法直接将当前Activity所在的Task移到后台,同时保留activity顺序和状态。(类似Home键效果)

  • 貌似给activity 加上这个属性,可以去除长按土司
  • 设置字体
logo.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/Figa.ttf"));
  • Edittext设置无焦点
         
  • 打开手机设置界面
/**     * 打开网络设置界面     */    public static void openSetting(Activity activity) {        Intent intent = new Intent("/");        ComponentName cm = new ComponentName("com.android.settings",                "com.android.settings.WirelessSettings");        intent.setComponent(cm);        intent.setAction("android.intent.action.VIEW");        activity.startActivityForResult(intent, 0);    }
  • 键盘把页面顶上去的
android:windowSoftInputMode="adjustResize|stateAlwaysVisible"

更多相关文章

  1. Android根据电量变化为不同图片的方法【电池电量提示】
  2. Android 图片旋转(使用Matrix.setRotate方法)
  3. Android之关于手势操作图片的缩放与移动
  4. Android的TextView使用Html来处理图片显示、字体样式、超链接等
  5. Android volley框架加载网络图片
  6. android 网络图片查看器
  7. Android 图片压缩
  8. android 网络请求图片

随机推荐

  1. 文档安全软件如何实现USB的安全管控与设
  2. 3、存储管理
  3. spring最常用的7种注解整理,让你在工作中
  4. 进程管理
  5. 智慧城市知识图谱模型与本体构建方法
  6. 用go编写prometheus自研exporter——CPU
  7. Linux运维入门教程04-01 (用户、群组和权
  8. 一文详解数栈FlinkX实时采集原理与使用
  9. 利用expect 工具批量分发公钥给SVR,实现
  10. 推荐四个事半功倍小工具(vscode也算小工具