Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

showing black background in api 21 #4

Open
mohamadk opened this issue Dec 2, 2015 · 5 comments
Open

showing black background in api 21 #4

mohamadk opened this issue Dec 2, 2015 · 5 comments
Labels

Comments

@mohamadk
Copy link

mohamadk commented Dec 2, 2015

hi albert thanks for this very nice lib.
i use it in my app but in api 21 polygone shows black background or transparent even if have parent with colored background.

device-2015-12-02-110924

this is my code

 PolygonImageView view = new PolygonImageView(getApplicationContext());
 view.setImageResource(R.color.info_MainBackColor);

 view.addBorderResource(5, R.color.info_MainBackColor);
 view.setCornerRadius(2);
 view.setVertices(6);
 imageLayout.addView(view);

this is my layout

  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
   android:id="@+id/mainlay"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:background="@color/amber_600"
 RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mainlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/amber_600"
 >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

           <RelativeLayout
        android:id="@+id/imageLayout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="30dp">
</RelativeLayout>
</LinearLayout>
@AlbertGrobas
Copy link
Owner

Sorry for no answering you before!
I'll take a look soon, I promise.

Thank you!

@sundyli
Copy link

sundyli commented Apr 5, 2017

I also encountered this problem, how should solve?

@sundyli
Copy link

sundyli commented Apr 6, 2017

Uploading image.jpg…

@mathieuedet
Copy link

mathieuedet commented Apr 26, 2017

I encountered this problem too. I don't know if you find solution but I think the problem is when layout size, or visibility change...

EDIT : Finally, I solved this by replacing :
setLayerType(View.LAYER_TYPE_SOFTWARE, null);

by

setLayerType(View.LAYER_TYPE_HARDWARE, null);

in PolygonImageView.java in init() method

I hope it will help someone :D

@abiemann
Copy link

that setLayerType() will disable hardware acceleration for the view.
More info: https://developer.android.com/guide/topics/graphics/hardware-accel.html#determining

(could be useful for Albert to research a fix)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants