Android TV: unfocused image contains black transparent background?

Pangu :

My Android TV app fetches images from a server and displays it on the home screen. The problem is, all the images that are not focused, i.e. not selected contains a black transparent background.

The only image that does not contain a transparent background is the currently selected image. I ensured that the images were pngs. As soon as the image is focused, the background is removed.

I'm not using a LinearLayout or anything in the .xml, just a GridItemPresenter class.

What is causing this and how can I fix this?

I tried to add the following view.setBackgroundColor(Color.TRANSPARENT) but that has no effect.

Here's my code:

private class GridItemPresenter extends Presenter
{
    public ViewHolder onCreateViewHolder(ViewGroup parent)
    {       
        ImageView view = new ImageView(parent.getContext());

        view.setBackgroundColor(Color.TRANSPARENT);

        view.setLayoutParams(new ViewGroup.LayoutParams((int)x, (int)y));
        view.setFocusable(true);
        view.setFocusableInTouchMode(true);
            return new ViewHolder(view);
    }

    public void onBindViewHolder(ViewHolder viewHolder, Object item)
    {
        ImageView imageView = ( (ImageView) viewHolder.view);

    }

    public void onUnbindViewHolder(ViewHolder viewHolder)
    {
        ImageView imageView = ( (ImageView) viewHolder.view);
    }
}

The face contains a black background when un-selected, but since it is selected, the background is not there: enter image description here

chinaanihchen :

I found a way to fix this. VertiGridPresenter's dimmer default is true , set it to false like:

VerticalGridPresenter gridPresenter = new VerticalGridPresenter(FocusHighlight.ZOOM_FACTOR_NONE, false);

or change the theme item <item name="overlayDimDimmedLevel">10%</item> in @style/Theme.Leanback, the percent value set the transparent value when set 100% the background will black.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=457099&siteId=1