android.widget.Spinner.setPadding()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(2.2k)|赞(0)|评价(0)|浏览(110)

本文整理了Java中android.widget.Spinner.setPadding()方法的一些代码示例,展示了Spinner.setPadding()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Spinner.setPadding()方法的具体详情如下:
包路径:android.widget.Spinner
类名称:Spinner
方法名:setPadding

Spinner.setPadding介绍

暂无

代码示例

代码示例来源:origin: TeamWalrus/Walrus

viewGroup.addView(choiceViewGroup);
spinner.setPadding(0, (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
    spinner.getResources().getDisplayMetrics()), 0, 0);

代码示例来源:origin: stackoverflow.com

Spinner s = (Spinner) findViewById(R.id.spinner);
s.setPadding(0, s.getPaddingTop(), s.getPaddingRight(), s.getPaddingBottom());

代码示例来源:origin: derry/delion

spinner.setDropDownWidth(ViewGroup.LayoutParams.MATCH_PARENT);
spinner.setPadding(0, 0, 0, 0);
dialogContainer.addView(spinner);

代码示例来源:origin: Ronak-LM/memoir

private <T extends SpinnerItem> SpinnerItemAdapter<T> createDropDownNav(Spinner spinner, int spinnerId, int spinnerItemId,
                                    SpinnerItems<T> spinnerItems,
                                    final DropDownNavListener<T> listener) {
  if (spinner != null) {
    Context context = getContext();
    // create custom adapter
    final SpinnerItemAdapter<T> dropDownNavAdapter = new SpinnerItemAdapter<>(context, spinnerItems, spinnerId, spinnerItemId);
    // configure spinner
    spinner.setPadding(spinner.getPaddingLeft(), 0, spinner.getPaddingRight(), 0);
    spinner.setAdapter(dropDownNavAdapter);
    // we need this because otherwise the first item will be selected by
    // default and the OnItemSelectedListener won't get called
    spinner.setSelection(spinnerItems.getSelectedItem());
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
      private AtomicBoolean mFirstCall = new AtomicBoolean(true);
      @Override
      public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
        if (!mFirstCall.getAndSet(false) && dropDownNavAdapter.getSelectedItem() != position) {
          listener.onItemSelected(dropDownNavAdapter.getItem(position), position);
        }
        dropDownNavAdapter.setSelectedItem(position);
      }
      @Override
      public void onNothingSelected(AdapterView<?> parent) {
      }
    });
    return dropDownNavAdapter;
  }
  return null;
}

代码示例来源:origin: FarbodSalamat-Zadeh/UsefulViews

mSpinner.setPadding(0, dpToPixels(8), 0, dpToPixels(8));
mSpinner.setOnItemSelectedListener(this);

相关文章