當前位置: 首頁>>代碼示例>>Java>>正文


Java Spinner.setPadding方法代碼示例

本文整理匯總了Java中android.widget.Spinner.setPadding方法的典型用法代碼示例。如果您正苦於以下問題:Java Spinner.setPadding方法的具體用法?Java Spinner.setPadding怎麽用?Java Spinner.setPadding使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.Spinner的用法示例。


在下文中一共展示了Spinner.setPadding方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initializeViews

import android.widget.Spinner; //導入方法依賴的package包/類
private void initializeViews(Context context, AttributeSet attrs) {
    TypedArray typedArray = context.obtainStyledAttributes(
            attrs,
            R.styleable.LabelledSpinner,
            0,
            0);
    String labelText = typedArray.getString(R.styleable.LabelledSpinner_labelText);
    mWidgetColor = typedArray.getColor(R.styleable.LabelledSpinner_widgetColor,
            getResources().getColor(R.color.widget_labelled_spinner));
    typedArray.recycle();

    LayoutInflater inflater =
            (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.widget_labelled_spinner, this, true);

    setOrientation(LinearLayout.VERTICAL);
    setLayoutParams(new LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    mLabel = (TextView) getChildAt(0);
    mLabel.setText(labelText);
    mLabel.setPadding(0, dpToPixels(16), 0, 0);
    mLabel.setTextColor(mWidgetColor);

    mSpinner = (Spinner) getChildAt(1);
    mSpinner.setPadding(0, dpToPixels(8), 0, dpToPixels(8));
    mSpinner.setOnItemSelectedListener(this);

    mDivider = getChildAt(2);
    MarginLayoutParams dividerParams =
            (MarginLayoutParams) mDivider.getLayoutParams();
    dividerParams.rightMargin = dpToPixels(4);
    dividerParams.bottomMargin = dpToPixels(8);
    mDivider.setLayoutParams(dividerParams);
    mDivider.setBackgroundColor(mWidgetColor);
    alignLabelWithSpinnerItem(4);
}
 
開發者ID:adithya321,項目名稱:SOS-The-Healthcare-Companion,代碼行數:39,代碼來源:LabelledSpinner.java

示例2: showCertificateChain

import android.widget.Spinner; //導入方法依賴的package包/類
private void showCertificateChain(byte[][] derData) {
    for (int i = 0; i < derData.length; i++) {
        addCertificate(derData[i]);
    }
    ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(mContext,
            android.R.layout.simple_spinner_item,
            mTitles) {
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            TextView view = (TextView) super.getView(position, convertView, parent);
            // Add extra padding on the end side to avoid overlapping the dropdown arrow.
            ApiCompatibilityUtils.setPaddingRelative(view, mPadding, mPadding, mPadding * 2,
                    mPadding);
            return view;
        }
    };
    arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    LinearLayout dialogContainer = new LinearLayout(mContext);
    dialogContainer.setOrientation(LinearLayout.VERTICAL);

    TextView title = new TextView(mContext);
    title.setText(R.string.certtitle);
    ApiCompatibilityUtils.setTextAlignment(title, View.TEXT_ALIGNMENT_VIEW_START);
    ApiCompatibilityUtils.setTextAppearance(title, android.R.style.TextAppearance_Large);
    title.setTypeface(title.getTypeface(), Typeface.BOLD);
    title.setPadding(mPadding, mPadding, mPadding, mPadding / 2);
    dialogContainer.addView(title);

    Spinner spinner = new Spinner(mContext);
    ApiCompatibilityUtils.setTextAlignment(spinner, View.TEXT_ALIGNMENT_VIEW_START);
    spinner.setAdapter(arrayAdapter);
    spinner.setOnItemSelectedListener(this);
    spinner.setDropDownWidth(ViewGroup.LayoutParams.MATCH_PARENT);
    // Remove padding so that dropdown has same width as the spinner.
    spinner.setPadding(0, 0, 0, 0);
    dialogContainer.addView(spinner);

    LinearLayout certContainer = new LinearLayout(mContext);
    certContainer.setOrientation(LinearLayout.VERTICAL);
    for (int i = 0; i < mViews.size(); ++i) {
        LinearLayout certificateView = mViews.get(i);
        if (i != 0) {
            certificateView.setVisibility(LinearLayout.GONE);
        }
        certContainer.addView(certificateView);
    }
    ScrollView scrollView = new ScrollView(mContext);
    scrollView.addView(certContainer);
    dialogContainer.addView(scrollView);

    showDialogForView(dialogContainer);
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:54,代碼來源:CertificateViewer.java


注:本文中的android.widget.Spinner.setPadding方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。