I use in my project such PinLockView: https://github.com/aritraroy/PinLockView

And everything works well, but with inflite views from the service:

public void alertPin(String pkdName){ view_pin = View.inflate(this, R.layout.activity_lock_pin, null); pinLockView = (PinLockView) view_pin.findViewById(R.id.pin_lock_view_Pin); indicatorDots = (IndicatorDots) view_pin.findViewById(R.id.indicator_dots_Pin); pinLockView.attachIndicatorDots(indicatorDots); ... Handler h = new Handler(getMainLooper()); h.post(new Runnable() { @Override public void run() { final WindowManager.LayoutParams params = new WindowManager.LayoutParams( WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.TYPE_SYSTEM_ERROR, WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN, PixelFormat.TRANSPARENT); wm.addView(view_pin, params); } }); } 

activity_lock_pin.xml

 <?xml version="1.0" encoding="utf-8"?> <com.andrognito.pinlockview.IndicatorDots android:id="@+id/indicator_dots_Pin" android:layout_width="match_parent" android:layout_height="wrap_content" app:dotDiameter="10dp" app:dotSpacing="8dp" app:dotEmptyBackground="@drawable/sg_dot_empty" app:dotFilledBackground="@drawable/sg_dot_filled" android:layout_above="@+id/pin_lock_view_Pin" android:layout_centerHorizontal="true" android:gravity="center" /> <com.andrognito.pinlockview.PinLockView android:id="@+id/pin_lock_view_Pin" android:layout_width="300dp" android:layout_height="wrap_content" app:keypadButtonSize="65dp" app:keypadTextSize="24dp" app:keypadShowDeleteButton="true" app:pinLength="4" app:keypadTextColor="@color/colorTextPrimary" app:keypadDeleteButtonDrawable="@drawable/ic_backspace_64dp" app:keypadDeleteButtonSize="40dp" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:paddingLeft="10dp" /> </RelativeLayout> 

layout_number_item:

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:clipChildren="false" android:clipToPadding="false" android:orientation="vertical"> <Button android:id="@+id/button" android:layout_width="64dp" android:layout_height="64dp" android:background="?selectableItemBackgroundBorderless/> </LinearLayout> 

layout_delete_item:

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:clipChildren="false" android:clipToPadding="false" android:gravity="center" android:orientation="vertical"> <LinearLayout android:id="@+id/button" android:layout_width="64dp" android:layout_height="64dp" android:clickable="true" android:gravity="center"> <ImageView android:id="@+id/buttonImage" android:layout_width="@dimen/default_delete_button_size" android:layout_height="@dimen/default_delete_button_size" android:adjustViewBounds="true" android:clickable="false" android:focusable="false" android:scaleType="fitCenter" android:src="@drawable/ic_backspace_64dp" /> </LinearLayout> 

Climbs the following:

 android.view.InflateException: Binary XML file line #9: Error inflating class android.widget.Button at android.view.LayoutInflater.createView(LayoutInflater.java:640) at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55) at android.view.LayoutInflater.onCreateView(LayoutInflater.java:689) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:748) at android.view.LayoutInflater.rInflate(LayoutInflater.java:813) at android.view.LayoutInflater.inflate(LayoutInflater.java:511) at android.view.LayoutInflater.inflate(LayoutInflater.java:415) at com.andrognito.pinlockview.PinLockAdapter.onCreateViewHolder(PinLockAdapter.java:41) 

An error occurs in the PinLockAdapter.class adapter

 @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { RecyclerView.ViewHolder viewHolder; if (viewType == VIEW_TYPE_NUMBER) { View view = View.inflate(parent.getContext(),R.layout.layout_number_item, null); viewHolder = new NumberViewHolder(view); } else { View view = View.inflate(parent.getContext(),R.layout.layout_delete_item, null); viewHolder = new DeleteViewHolder(view); } return viewHolder; } 

Tell me where to dig?

PS I want to note that the error appears only when calling from the Service

  • Show the view as a minimum. - Vladyslav Matviienko
  • one
    No, this is not the correct view. Enter the layout, on the inflate of which falls - Vladyslav Matviienko
  • show layout_delete_item or layout_number_item, depending on where you fall - Chaynik

1 answer 1

the error is here, so the background cannot be set:
android:background="?selectableItemBackgroundBorderless