从wearablelistview中删除空顶部区域

时间:2016-08-10 13:41:41

标签: android wear-os android-wear-2.0

我刚开始摆弄android穿sdk。我创建了一个列表,发现它通常呈现一个顶部空白区域。

enter image description here

我需要将其移除,但我无法找到任何内容。

1 个答案:

答案 0 :(得分:0)

转到Adapter类并添加如下代码:

private final Activity mContext;
private final Fragment[][] mFragment;

public MyGridViewPagerAdapter(Activity ctx, FragmentManager fm, Fragment[][] fragments)
{
  super(fm);
  mContext = ctx;
  this.mFragment = fragments;
}

然后覆盖以下方法:

@Override
public Fragment getFragment(int row, int col) 
{ 
  return mFragment[row][col]; 
}

@Override
public int getRowCount() 
{ 
  return mFragment.length; 
}

@Override
public int getColumnCount(int rowNum) 
{ 
  return mFragment[rowNum].length; 
}

然后在您的活动中执行以下操作:

@Override
protected void onCreate(Bundle savedInstanceState)
{
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_my);

  final GridViewPager pager = (GridViewPager) findViewById(R.id.pager);
  final Fragment[][] items = {
        {
                CusmtomFragment.newInstance("your","arguments"),
                CusmtomFragment.newInstance()
        },
        {
                OtherFragment.newInstance(),
                AnotherFragment.newInstance(1234)
        }
  };
  // ....
  pager.setAdapter(new MyGridViewPagerAdapter(this, getFragmentManager(), items));
}

还请检查此问题:Is there any way to detect if the clock is round?

希望它会有所帮助