要在RowsSupportFragment中减少行间距,您可以按照以下步骤操作:
创建一个新的类并继承RowsSupportFragment。
重写onCreateView()方法,并在其中调用super.onCreateView()。
修改RowsSupportFragment的默认值,以减少行间距。例如,您可以通过以下代码减少行间距:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);
int spacingInPixels = getResources().getDimensionPixelSize(R.dimen.leanback_rows_spacing);
((VerticalGridView) view.findViewById(R.id.browse_rows)).setVerticalSpacing(spacingInPixels);
return view;
}
在这个代码示例中,我们获取了另一个资源文件(R.dimen.leanback_rows_spacing),它包含了我们想要的行间距像素大小。然后,我们将这个值设置到VerticalGridView中。
这样就可以在RowsSupportFragment中减少行间距了。