App Widget中的Android循环Imageview

时间:2015-10-02 17:29:21

标签: android android-layout android-imageview android-appwidget

所以我正在尝试创建一个应用小部件,并在那里显示一个看起来像圆形ImageView的个人资料图片。 通常我只使用循环ImageView库,但对于应用小部件,您无法扩展视图(因此只有vanilla ImageView)并且必须使用RemoteViews < /强>

因此,我正在尝试使用Drawable覆盖/底层来实现此效果。我从这里Display FB profile pic in circular image view in Application尝试了gusridd的解决方案,但我的个人资料图片所在的背景也是一个图像,这只是一个带有圆形图像的白色正方形:(

编辑:请在回答之前阅读粗体部分:X

2 个答案:

答案 0 :(得分:4)

Feature: Authentication Checking Application Authentication Functionality. @javascript Scenario: Admin Redirect Page # app/tests/behat/features/auth.feature:5 Given I am on "/admin/dashboard" # FeatureContext::visit() Then I should be on "/admin/login" # FeatureContext::assertPageAddress() Scenario: Admin Redirect Page # app/tests/behat/features/auth.feature:9 Given I am on "/admin/dashboard" # FeatureContext::visit() Target [Illuminate\Contracts\Http\Kernel] is not instantiable. (Illuminate\Contracts\Container\BindingResolutionException) Then I should be on "/admin/login" # FeatureContext::assertPageAddress() Scenario: Admin Redirect Page # app/tests/behat/features/auth.feature:13 Given I am on "/admin/dashboard" # FeatureContext::visit() Target [Illuminate\Contracts\Http\Kernel] is not instantiable. (Illuminate\Contracts\Container\BindingResolutionException) Then I should be on "/admin/login" # FeatureContext::assertPageAddress() --- Failed scenarios: app/tests/behat/features/auth.feature:9 app/tests/behat/features/auth.feature:13 3 scenarios (1 passed, 2 failed) 6 steps (2 passed, 2 failed, 2 skipped) 0m2.87s (24.19Mb) 使用Notification也遇到了同样的问题。

为此,我使用了这个: http://curious-blog.blogspot.co.il/2014/05/create-circle-bitmap-in-android.html

并致电RemoteViews的{​​{1}}。

答案 1 :(得分:0)

我在使用RemoteView的“自定义通知”中遇到了相同的问题,然后采用以下解决方案可以解决问题。

解决方案:使用圆形裁剪的位图

public Bitmap getCroppedBitmap(Bitmap bitmap) throws Exception {
    Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(output);

    final int color = 0xff424242;
    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());

    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);
    canvas.drawCircle(bitmap.getWidth() / 2, bitmap.getHeight() / 2, bitmap.getWidth() / 2, paint);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);
    return output;
}