Android 你如何膨胀远程视图?

Android 你如何膨胀远程视图?,android,remoteview,Android,Remoteview,我正在尝试获取RemoteView中用于通知的ImageButton的高度,以便创建一个方形位图应用于它。问题是,当我对inflate()返回的视图进行充气时,高度为0。我假设这是因为传递给RemoteView的父级“apply()为空 是否存在用于通知的父视图组?有没有办法在充气后获取通知中ImageButton的高度 以下是我尝试过的: // This is where the parent is null. View view = remoteViewNo

我正在尝试获取RemoteView中用于通知的ImageButton的高度,以便创建一个方形位图应用于它。问题是,当我对
inflate()
返回的视图进行充气时,高度为0。我假设这是因为传递给RemoteView的父级“
apply()
为空

是否存在用于通知的父视图组?有没有办法在充气后获取通知中ImageButton的高度

以下是我尝试过的:

        // This is where the parent is null. 
        View view = remoteViewNotificationLayout.apply(this, null);
        LayoutInflater layoutInflater = (LayoutInflater) getSystemService( Context.LAYOUT_INFLATER_SERVICE );
        // Not sure what ViewGroup to use
        view = layoutInflater.inflate(R.layout.notification_song_pane, (ViewGroup) view.getRootView());
        ImageView imageView = view.findViewById(R.id.imageButtonNotificationSongPaneNext);
        int height = imageView.getMeasuredHeight();
        //noinspection SuspiciousNameCombination
        int width = height;
        Drawable drawable = getResources().getDrawable(R.drawable.skip_next_black_24dp);
        drawable.setBounds(0, 0, width, height);
        // I get an exception here because width and height are 0
        Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        drawable.draw(canvas);
        // Convenience method for creating the square Bitmap
        Bitmap bitmapResized = FragmentSongPane.getResizedBitmap(bitmap, width, height);
        bitmap.recycle();
        remoteViewNotificationLayout.setBitmap(R.id.imageButtonNotificationSongPaneNext, "setImageBitmap", bitmapResized);
        view = remoteViewNotificationLayout.apply(this, null);
        remoteViewNotificationLayout.reapply(this, view);
        builder.setContent(remoteViewNotificationLayout);