小编zed*_*zed的帖子

android:动画颜色从颜色变为颜色

假设我有两种颜色,我需要创建一个快速从颜色切换到另一种颜色的实时动画.

我试图增加十六进制的颜色,直到我到达另一个,但这给了一个非常糟糕的动画,因为它显示了许多不相关的颜色.

setColorFilter(color, colorfilter)用来改变imageview的颜色.

改变HUE会给我最好的视觉效果吗?如果是这样,我怎样才能将其改为纯色?

解决方案:我通过递归移位色调来解决它

private int hueChange(int c,int deg){
       float[] hsv = new float[3];       //array to store HSV values
       Color.colorToHSV(c,hsv); //get original HSV values of pixel
       hsv[0]=hsv[0]+deg;                //add the shift to the HUE of HSV array
       hsv[0]=hsv[0]%360;                //confines hue to values:[0,360]
       return Color.HSVToColor(Color.alpha(c),hsv);
    }
Run Code Online (Sandbox Code Playgroud)

android colors

46
推荐指数
8
解决办法
5万
查看次数

Android:在运行时获取TargetSDKVersion

我可以在运行时获取使用过的TargetSDKVersion吗?

这是因为Android API 19中的WebView处理像素的方式与19之前不同.

这是一个库,所以我不想让开发人员手动输入它.

我的评论:我正在使用我的Nexus 5 API 21 Lollipop.更改TargetSDKVersion会改变html的javascript读取宽度的方式,屏幕密度的倍数.我刚刚将其更改为14然后更改为19,我确认了这一点.

android

7
推荐指数
3
解决办法
7486
查看次数

Cloudformation:没有Internet路由的VPC路由表

我正在使用CloudFormation创建整个堆栈.我注意到即使我有一个0.0.0.0/0的路由规则来访问我的云形成模板中的Internet网关,它也没有被创建.

VPC:

"vpc": {
  "Type": "AWS::EC2::VPC",
  "Properties": {
    "CidrBlock": "172.31.0.0/16",
    "InstanceTenancy": "default",
    "EnableDnsSupport": "true",
    "EnableDnsHostnames": "true",
    "Tags": [
      {
        "Key": "Environment",
        "Value": {
          "Ref": "Env"
        }
      }
    ]
  }
Run Code Online (Sandbox Code Playgroud)

路由表:

"rtb": {
  "Type": "AWS::EC2::RouteTable",
  "Properties": {
    "VpcId": {
      "Ref": "vpc"
    }
  },
  "Metadata": {
    "AWS::CloudFormation::Designer": {
      "id": "65297cdc-8bcd-482d-af40-b0fef849b8c2"
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

VPCGatewayAttachment:

"gw1": {
  "Type": "AWS::EC2::VPCGatewayAttachment",
  "Properties": {
    "VpcId": {
      "Ref": "vpc"
    },
    "InternetGatewayId": {
      "Ref": "ig"
    }
  },
  "Metadata": {
    "AWS::CloudFormation::Designer": {
      "id": "aa69d6c0-3b11-43be-a8c1-7e79176f8c89"
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

路线:

"route1": …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services aws-cloudformation

7
推荐指数
1
解决办法
2534
查看次数

Zend Framework 2:Composer\Autoload\includeFile很慢

根据New Relic事务跟踪器,有时Composer\Autoload\includeFile需要大约318毫秒才能加载我的项目.

我从作曲家那里抛弃了一个类图,但它仍然没有区别.

composer.json 需要以下内容:

"require": {
        "php": ">=5.3.3",
        "zendframework/zendframework": "2.4.*",
        "zendframework/zendservice-amazon": "2.*",
        "wisembly/elephant.io": "~3.0",
        "knplabs/github-api": "~1.2"
    }
Run Code Online (Sandbox Code Playgroud)

我的ZF2应用程序中只有一个模块.

我的ZF2自动加载如何更快地执行?

php zend-framework autoload composer-php

5
推荐指数
1
解决办法
1286
查看次数

Android BLE:服务中发现的特征列表不完整

尝试从 GATT 服务读取特征时,与我从 iOS 设备或制造商指南获得的列表相比,该列表不完整。

我正在阅读的特征如下:

private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
        @Override
        public void onConnectionStateChange(BluetoothGatt gatt, int status,
                                            int newState) {
            if (newState == BluetoothProfile.STATE_CONNECTED) {
                mConnectionState = STATE_CONNECTED;
                mBluetoothGatt = gatt;
                if (shouldStartWriting && writeCharacteristicsQueue.peek() != null) {
                    mBluetoothGatt.writeCharacteristic(writeCharacteristicsQueue.poll());
                } else {
                    EventBus.getDefault().post(new BTGattStatusEvent(BTGattStatusEvent.Status.CONNECTED));
                    Log.i(TAG, "Attempting to start service discovery:" +
                            gatt.discoverServices());
                }

            } else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
                mConnectionState = STATE_DISCONNECTED;
                mBluetoothGatt = null;
                EventBus.getDefault().post(new BTGattDisconnectedEvent());
            }
        }

        @Override
        // New services discovered
        public …
Run Code Online (Sandbox Code Playgroud)

android bluetooth-lowenergy gatt

5
推荐指数
0
解决办法
1679
查看次数

android:公共目录中的内部存储中保存文件

我试图将图像保存在app文件目录中的公共目录中.通过公开,我的意思是我将能够使用动作视图意图.

/** Saves the bitmap to app storage */
    public int SaveBitmap(Bitmap bitmap, String filename, Boolean scan){

        // Save the file
        OutputStream os = null;

        String path = context.getFilesDir() + "/MyAppName/";
        File file = new File(path);
        if(!file.isDirectory())file.mkdirs();
        path += (filename + ".png");
        try {
            os = new BufferedOutputStream(new FileOutputStream(path,true));
            //os = mContext.openFileOutput(, Context.MODE_PRIVATE);
            bitmap.compress(CompressFormat.PNG, 100, os);
            os.flush();
            os.close();
            bitmap.recycle();
        } catch (IOException e) {
            e.printStackTrace();
            return 1; //Failure
        }

        File fileR = new File(path);

        fileR.setReadable(true, false);
        // Show in Gallery …
Run Code Online (Sandbox Code Playgroud)

android

4
推荐指数
2
解决办法
1万
查看次数