小编Zen*_*Zen的帖子

在Android中使用ColorMatrixFilter减去混合模式?

我有以下ColorMatrixFilter.但我想将它用作Subtract-Blend模式的掩码,而不是直接使用它.我该如何实现这一目标?

嘉洛斯:

colorMatrix[
        0.393, 0.7689999, 0.18899999, 0, 0,
        0.349, 0.6859999, 0.16799999, 0, 0,
        0.272, 0.5339999, 0.13099999, 0, 0,
        0,     0,         0,          1, 0
    ];
Run Code Online (Sandbox Code Playgroud)

java android opengl-es colormatrix

54
推荐指数
2
解决办法
817
查看次数

如何使用GPUImageLibrary"减去"滤色器?

目前BlendModes(减去,排除等)使用LauncherImage作为掩码.我可以将这些BlendModes应用于ColorMatrix吗?

我正在使用GPUImageLibrary:

colorMatrix[
    0.393, 0.7689999, 0.18899999, 0, 0,
    0.349, 0.6859999, 0.16799999, 0, 0,
    0.272, 0.5339999, 0.13099999, 0, 0,
    0,     0,         0,          1, 0];
Run Code Online (Sandbox Code Playgroud)

SubtractBlendFilter.java

public class GPUImageSubtractBlendFilter extends GPUImageTwoInputFilter {
    public static final String SUBTRACT_BLEND_FRAGMENT_SHADER = "varying highp vec2 textureCoordinate;\n" +
            " varying highp vec2 textureCoordinate2;\n" +
            "\n" +
            " uniform sampler2D inputImageTexture;\n" +
            " uniform sampler2D inputImageTexture2;\n" +
            " \n" +
            " void main()\n" +
            " {\n" +
            "   lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" +
            " …
Run Code Online (Sandbox Code Playgroud)

java android opengl-es gpuimage

46
推荐指数
1
解决办法
696
查看次数

检查AnimatorSet是否已完成动画?

我正在尝试使用淡入淡出动画来设置动画 AnimatorSet

Button fades in > Click button > Remaining buttons fade out

所以为了做到这一点,我想设置onClickListner after the animation is completed,但这似乎不起作用.单击动画中间的按钮triggers the onClick action:

setQuestion = new AnimatorSet();           
setQuestion.playSequentially(fadeinAnimationQ,fadeinAnimation1,fadeinAnimation2,fadeinAnimation3,fadeinAnimation4,fadeinAnimation5);
setQuestion.start();
Run Code Online (Sandbox Code Playgroud)

这是检查的方法if the animation has finished.

private void checkAnimation() {
    while (true) {
        // Check if animation has ended
        if (setQuestion.isRunning() == false) {
            assignListners();
            break;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

animation android objectanimator

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

Android:在LockScreen上覆盖TextView

概念

我试图在LockScreen上叠加TextView(类似于Android覆盖时间的方式).

注意:我不想绕过锁屏,只是在它上面画画(不干扰任何触摸事件).

我尝试使用以下标志(在onCreate中):

getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    getWindow().addFlags(WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);
    getWindow().addFlags(PixelFormat.TRANSLUCENT);
Run Code Online (Sandbox Code Playgroud)

并应用以下主题(针对特定活动):

   <style name="Transparent">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowActionBar">false</item>
    <item name="android:backgroundDimEnabled">false</item>
 <item name="android:windowIsFloating">true</item>   
</style>
Run Code Online (Sandbox Code Playgroud)

但这会占据锁定屏幕的TOP,隐藏锁屏并禁用所有触摸事件.

编辑:activity_overlay.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.coco.MainActivity" >

<TextView
    android:id="@+id/textView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textColor="@android:color/white"
    android:layout_alignParentBottom="true"
    android:text="TextView" />

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

活动的清单声明(膨胀overlay_activity.xml)

      <activity
        android:name=".DisplayActivity"
        android:label="@string/app_name"
        android:theme="@style/Transparent" />
Run Code Online (Sandbox Code Playgroud)

android overlay textview android-windowmanager

12
推荐指数
1
解决办法
6526
查看次数

使用Google+ AccessToken创建新的ParseUser会返回InvalidSession吗?

我正在尝试使用Google+ SignIn创建新的ParseUser.虽然我能够从Google成功检索访问令牌,但我得到了一个ParseException(InvalidSession).我将发布几个相关的片段.

这就是我从谷歌获取AccessToken的方式

final String SCOPES = "https://www.googleapis.com/auth/plus.login ";  
token = GoogleAuthUtil.getToken(
    MainActivity.this,
    Plus.AccountApi.getAccountName(mGoogleApiClient),
    "oauth2:" + SCOPES);
Run Code Online (Sandbox Code Playgroud)

制作ParseUser

ParseUser.becomeInBackground(token, new LogInCallback()
{
    public void done(ParseUser user, ParseException e) 
    {
        Log.i(TAG, "makeParseUser"+"2");
        if (user != null)
        {
            // The current user is now set to user.
            /*
            user.put("name", s1);
            user.put("email",s6);
            user.saveInBackground();
            */
        }else 
        {
            // The token could not be validated.
            Log.i(TAG, "makeParseUser"+e.getLocalizedMessage());
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

这里也提出类似的问题,但似乎没有一个合适的解决方案.

android google-plus parse-platform

11
推荐指数
1
解决办法
529
查看次数

Spannable RecyclerView像Snapchat-Discover

我试图使用TwoWayView库创建一个spannable recyclerView,如下图所示:https://github.com/lucasr/twoway-view

但是我无法获得所需的视图,并且遗漏了空单元格.

        final SpannableGridLayoutManager.LayoutParams lp = (SpannableGridLayoutManager.LayoutParams) itemView.getLayoutParams();

        //final int span1 = (itemId == 0 || itemId == 3 ? 2 : 1);
        //final int span2 = (itemId == 0 ? 2 : (itemId == 3 ? 3 : 1));

        int span1 = 0; //h
        int span2 = 0; //w

        switch(itemId)
        {
        case 0:
            span1 = 2;
            span2 = 1;
            break;

        case 1:
            span1 = 2;
            span2 = 1;
            break;

        case 2:
            span1 = 2;
            span2 …
Run Code Online (Sandbox Code Playgroud)

android snapchat android-recyclerview

10
推荐指数
1
解决办法
1853
查看次数

Switch-Button拇指歪斜了吗?

我的Switch按钮的拇指似乎变得歪斜(开启和关闭状态).在github上也有类似的问题,但那些是人们在API 4.0中使库支持Switch按钮 -

main包含开关按钮,并且有一个拇指和轨道可绘制的应用程序

这就是发生的事情:

在此输入图像描述

这就是它的假设:

在此输入图像描述

switch_track_on.png

在此输入图像描述

main.xml中

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<Switch
    android:id="@+id/switch1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="112dp"
    android:thumb="@drawable/switch_thumb_selector"
    android:track="@drawable/switch_track_selector"
    android:textOn=""
    android:textOff=""/>

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

switch_thumb_selector.xml

<selector>
<item android:drawable="@drawable/switch_thumb">
</item>
</selector>
Run Code Online (Sandbox Code Playgroud)

switch_track_selector.xml

    <selector>
<item android:drawable="@drawable/switch_track_on" android:state_checked="true"/>
<item android:drawable="@drawable/switch_track_off" android:state_checked="false"/>
</selector> 
Run Code Online (Sandbox Code Playgroud)

xml android android-switch

8
推荐指数
3
解决办法
7891
查看次数

使用Tesseract的Android OCR App

我正在按照本网站提到的教程:

http://gaut.am/making-an-ocr-android-app-using-tesseract/

首先我从github 导入了Tess-Two:https: //github.com/rmtheis/tess-two

并将其链接到我的项目 https://github.com/GautamGupta/Simple-Android-OCR

该应用程序编译并运行正常.但点击图片后,我点击保存它崩溃.

以下是源主要活动:

public class SimpleAndroidOCRActivity extends Activity {
  public static final String PACKAGE_NAME = "com.datumdroid.android.ocr.simple";
  public static final String DATA_PATH = Environment
                    .getExternalStorageDirectory().toString() + "/SimpleAndroidOCR/";

  // You should have the trained data file in assets folder
  // You can get them at:
  // http://code.google.com/p/tesseract-ocr/downloads/list
  public static final String lang = "eng";

  private static final String TAG = "SimpleAndroidOCR.java";

  protected Button _button;
  // protected ImageView _image;
  protected EditText _field;
  protected …
Run Code Online (Sandbox Code Playgroud)

ocr android tesseract

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

Android加载自定义数字选择器Drawable [图片内部]

左边是android的默认数字选择器.如果我有可绘制的图像,是否可以加载右侧的自定义数字选择器?

NumberPicker

android android-ui numberpicker

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

Android:从字符串值中提取链接

我想要来自共享意图的链接。当我通过 Chrome 收到链接时,其格式正确,但有时其他应用程序也会添加文本。

例子:

Chrome:“www.recode.net/2016/7/21/12243560/google-machine-learning-comics-play”

Twitter: "大家看看这个链接,它太酷了https://www.recode.net/2016/7/21/12243560/google-machine-learning-comics-play "

因此,如果是 Twitter,我想删除所有上下文,只保留链接,即 www.recode.net/2016/7/21/12243560/google-machine-learning-comics-play

注意:链接可以是任何格式 https://..(或)www. ..(或)recode.net/...(开头不带 www)。

有正则表达式可以解决这个问题吗?

@Override
protected void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_shareintent);

    // Get intent, action and MIME type
    Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();

    if (Intent.ACTION_SEND.equals(action) && type != null) 
    {
        if ("text/plain".equals(type)) 
        {
            // Handle text being sent
            handleSendText(intent); 
        }
    }
}

void handleSendText(Intent intent)
{
    String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
    if (sharedText != null) 
    {
        // Update UI to …
Run Code Online (Sandbox Code Playgroud)

java regex android

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