gpt4 book ai didi

Android TV RowsFragment - 无法禁用行调光效果

转载 作者:行者123 更新时间:2023-12-05 08:33:20 26 4
gpt4 key购买 nike

我有一个扩展 RowsFragment 的 fragment ,无论我尝试什么,我都无法禁用未选中行的调光效果(第一张图片)。

Can't disable the dimming of unselected rows

这是我的代码:

public class MainFragment extends RowsFragment {
private static final String TAG = MainFragment.class.getSimpleName();

private ArrayObjectAdapter mRowsAdapter;
private static final int GRID_ITEM_WIDTH = 300;
private static final int GRID_ITEM_HEIGHT = 200;

@Override
public void onActivityCreated(Bundle savedInstanceState) {
Log.i(TAG, "onActivityCreated");
super.onActivityCreated(savedInstanceState);

loadRows();

}

private void loadRows() {
mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter(FocusHighlight.ZOOM_FACTOR_LARGE, false));


HeaderItem cardPresenterHeader = new HeaderItem(1, "CardPresenter");
CardPresenter cardPresenter = new CardPresenter();
ArrayObjectAdapter cardRowAdapter = new ArrayObjectAdapter(cardPresenter);


for(int i=0; i<10; i++) {
Movie movie = new Movie();
movie.setTitle("title" + i);
movie.setStudio("studio" + i);
cardRowAdapter.add(movie);
}

mRowsAdapter.add(new ListRow(cardPresenterHeader, cardRowAdapter));
mRowsAdapter.add(new ListRow(cardPresenterHeader, cardRowAdapter));

setAdapter(mRowsAdapter);

}

无论我尝试什么更改或组合(使用 useFocusDimmer 标志,尝试使用 BrowseFragment 等)我都无法获得我正在寻找的结果。

我最接近的是更改为 VerticalGridFragment 和 Presenter,但缺少此功能,它只类似于我正在尝试完成的(第二张图片)。

Example of how I want it to look

提前致谢

最佳答案

您必须使用 RowsFragment连同 RowPresenter子类。在 RowPresenter 子类中,您可以定义自定义选择动画或尝试调用 setSelectEffectEnabled .

文档摘录:

When a user scrolls through rows, a fragment will initiate animation and call setSelectLevel(Presenter.ViewHolder, float) with float value between 0 and 1. By default, the RowPresenter draws a dim overlay on top of the row view for views that are not selected. Subclasses may override this default effect by having isUsingDefaultSelectEffect() return false and overriding onSelectLevelChanged(ViewHolder) to apply a different selection effect.

Call setSelectEffectEnabled(boolean) to enable/disable the select effect, This will not only enable/disable the default dim effect but also subclasses must respect this flag as well.

关于Android TV RowsFragment - 无法禁用行调光效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42089835/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com