0

在leanback library carousel中选择时,我试图使整行展开。

我想要的效果:我想要的效果

我正在处理 android TV 示例代码。我已经尝试setExpandedRowHeight(..);setRowHeight(..);

/**
 * Created by sylversphere on 15-03-16.
 */
public class ExperimentalFragment extends BrowseFragment{

    private ArrayObjectAdapter mRowsAdapter;
    private ExperimentalCardPresenter mCardPresenter;
    private int NUM_ROWS = 20;
    private int NUM_COLS = 40;
    private Context context;

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        context = getActivity();
        setTitle("Hello there you kid"); // Badge, when set, takes precedent
        setHeadersState(HEADERS_DISABLED);
        loadRows();
    }

    private void loadRows() {
        List<Movie> list = MovieList.setupMovies();

        final ListRowPresenter lrp = new ListRowPresenter(FocusHighlight.ZOOM_FACTOR_LARGE);
        lrp.setRowHeight(100);
        lrp.setExpandedRowHeight(200);

        mRowsAdapter = new ArrayObjectAdapter(lrp);

        mCardPresenter = new ExperimentalCardPresenter();

        int i;
        for (i = 0; i < NUM_ROWS; i++) {
            ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(mCardPresenter);
            for (int j = 0; j < NUM_COLS; j++) {
                listRowAdapter.add(list.get(j % 5));
            }
            mRowsAdapter.add(new ListRow(listRowAdapter));
        }

        setAdapter(mRowsAdapter);
    }

    private void say(String s) {
        Toast.makeText(context, "Say : "+s, Toast.LENGTH_SHORT).show();
    }
}

但行保持不变。我尝试手动为行设置动画,但现在行之间没有适当的填充。我将如何使行扩展并保持填充?

4

1 回答 1

1

通过使用 setExpandedRowHeight,您只是设置了高度,而不是真正扩展了行。当您希望通过调用setRowViewExpanded方法扩展行视图时,您需要显式设置行视图扩展

public final void setRowViewExpanded (Presenter.ViewHolder holder, boolean expanded)
于 2015-04-01T11:15:31.580 回答