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


Java AlignmentSpan類代碼示例

本文整理匯總了Java中android.text.style.AlignmentSpan的典型用法代碼示例。如果您正苦於以下問題:Java AlignmentSpan類的具體用法?Java AlignmentSpan怎麽用?Java AlignmentSpan使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: align

import android.text.style.AlignmentSpan; //導入依賴的package包/類
/**
 * add alignment for text
 *
 * @param indent LEFT, RIGHT, CENTER
 * @return Snippety
 */
public Snippety align(Indent indent) {
    AlignmentSpan span;
    switch (indent) {
        case RIGHT:
            span = new AlignmentSpan.Standard(Layout.Alignment.ALIGN_OPPOSITE);
            break;
        case CENTER:
            span = new AlignmentSpan.Standard(Layout.Alignment.ALIGN_CENTER);
            break;
        case LEFT:
        default:
            span = new AlignmentSpan.Standard(Layout.Alignment.ALIGN_NORMAL);
            break;
    }

    spans.add(span);

    return this;
}
 
開發者ID:Fueled,項目名稱:snippety,代碼行數:26,代碼來源:Snippety.java

示例2: handleBlockTag

import android.text.style.AlignmentSpan; //導入依賴的package包/類
private void handleBlockTag(boolean isStart, int type, int start, HtmlNode.HtmlAttr attr) {
    if (position <= 0) return;
    if (spannedBuilder.charAt(position - 1) != '\n') {
        spannedBuilder.append('\n');
        position++;
    }

    //結束block 標簽
    if (!isStart && attr != null) {
        Layout.Alignment align;
        if (attr.align == HtmlNode.ALIGN_LEFT) {
            align = Layout.Alignment.ALIGN_NORMAL;
        } else if (attr.align == HtmlNode.ALIGN_RIGHT) {
            align = Layout.Alignment.ALIGN_OPPOSITE;
        } else if (attr.align == HtmlNode.ALIGN_CENTER) {
            align = Layout.Alignment.ALIGN_CENTER;
        } else {
            align = null;
        }

        if (align != null) {
            setSpan(start, position, new AlignmentSpan.Standard(align));
        }
    }
}
 
開發者ID:freedom10086,項目名稱:Ruisi,代碼行數:26,代碼來源:SpanConverter.java

示例3: handleParagraph

import android.text.style.AlignmentSpan; //導入依賴的package包/類
private void handleParagraph(int start, HtmlNode.HtmlAttr attr) {
    if (attr == null) return;
    setSpan(start, new StyleSpan(attr));

    Layout.Alignment align;
    if (attr.textAlign == HtmlNode.ALIGN_LEFT) {
        align = Layout.Alignment.ALIGN_NORMAL;
    } else if (attr.textAlign == HtmlNode.ALIGN_RIGHT) {
        align = Layout.Alignment.ALIGN_OPPOSITE;
    } else if (attr.textAlign == HtmlNode.ALIGN_CENTER) {
        align = Layout.Alignment.ALIGN_CENTER;
    } else {
        align = null;
    }

    if (align != null) {
        setSpan(start, position, new AlignmentSpan.Standard(align));
    }
}
 
開發者ID:freedom10086,項目名稱:Ruisi,代碼行數:20,代碼來源:SpanConverter.java

示例4: about

import android.text.style.AlignmentSpan; //導入依賴的package包/類
private void about() {
    // 先移除所有的動態view
    linearLayout.removeView(recycle);
    linearLayout.removeView(recycle2);
    linearLayout.removeView(recycle3);
    linearLayout.removeView(about);
    linearLayout.removeView(explan);
    /* TODO 關於我們
    *
    *
    */

    String text = "\n\n\n開發成員 : \n\n陳亮宇\n張弘瑜\n鍾羽函\n蘇柏丞\n謝宣緯\n\n\n\n\t資料來源 : 行政院文化局";
    SpannableString spannable = new SpannableString(text);
    spannable.setSpan(new AbsoluteSizeSpan(80), 0, text.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
    spannable.setSpan(new AlignmentSpan.Standard(Layout.Alignment.ALIGN_CENTER), 0, text.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    spannable.setSpan(new ForegroundColorSpan(Color.parseColor("#FF533210")), 0, text.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);

    spannable.setSpan(new AbsoluteSizeSpan(100), 3, 7, Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
    spannable.setSpan(new AbsoluteSizeSpan(100), 36, 40, Spanned.SPAN_EXCLUSIVE_INCLUSIVE);

    about.setText(spannable);
    linearLayout.addView(about);

}
 
開發者ID:RedFishCHANG,項目名稱:ReadWorld,代碼行數:26,代碼來源:MainActivity.java

示例5: info

import android.text.style.AlignmentSpan; //導入依賴的package包/類
private void info() {
    // 先移除所有的動態view
    linearLayout.removeView(recycle);
    linearLayout.removeView(recycle2);
    linearLayout.removeView(recycle3);
    linearLayout.removeView(about);
    linearLayout.removeView(explan);
    /* TODO 說明
    *
    *
    */
    String text = "\n\n\n    這是一個彙整台灣獨立書店的app,資料取自文化局的開放資源,主要目的在於提供沒接觸過或是剛接觸獨立書店的民眾,可以找尋到自己生活周遭哪裡有獨立書店,該如何拜訪、參觀,並且了解各個獨立店家的特色";
    SpannableString spannable = new SpannableString(text);
    spannable.setSpan(new AbsoluteSizeSpan(80), 0, text.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
    spannable.setSpan(new AlignmentSpan.Standard(Layout.Alignment.ALIGN_NORMAL), 0, text.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    spannable.setSpan(new ForegroundColorSpan(Color.parseColor("#FF533210")), 0, text.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);

    explan.setText(spannable);
    linearLayout.addView(explan);

}
 
開發者ID:RedFishCHANG,項目名稱:ReadWorld,代碼行數:22,代碼來源:MainActivity.java

示例6: showArticle

import android.text.style.AlignmentSpan; //導入依賴的package包/類
@Override
public void showArticle(ArticleOne article) {
    String title = article.getArticleTitle();
    String author = article.getArticleAuthor();
    String content = article.getArticleContent();

    String text = title + "\n" + author + "\n\n" + content;
    SpannableStringBuilder style = new SpannableStringBuilder(text);
    style.setSpan(new AbsoluteSizeSpan(SystemUtil.dp2px(30)), 0, title.length(), Spanned
            .SPAN_EXCLUSIVE_INCLUSIVE);
    style.setSpan(new AbsoluteSizeSpan(SystemUtil.dp2px(20)), title.length() + 1, title
            .length() + 1 + author.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
    style.setSpan(new AlignmentSpan.Standard(Layout.Alignment.ALIGN_CENTER), 0, title
            .length() + 1 + author.length(), Spanned
            .SPAN_EXCLUSIVE_INCLUSIVE);
    style.setSpan(new AbsoluteSizeSpan(SystemUtil.dp2px(16)), title.length() + author
            .length() + 3, text.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);

    mTvContent.setText(style);
}
 
開發者ID:4FunApp,項目名稱:4Fun,代碼行數:21,代碼來源:ReadFragment.java

示例7: showContent

import android.text.style.AlignmentSpan; //導入依賴的package包/類
@Override
public void showContent(Movie movie) {
    String movieName = movie.getMovieName();
    String country = movie.getCountry();
    String briefIntro = movie.getBriefIntro();

    String content = movieName + "\n" + country + "\n" + briefIntro;
    SpannableStringBuilder style = new SpannableStringBuilder(content);
    style.setSpan(new AbsoluteSizeSpan(SystemUtil.dp2px(30)), 0, movieName.length(), Spanned
            .SPAN_EXCLUSIVE_INCLUSIVE);
    style.setSpan(new AbsoluteSizeSpan(SystemUtil.dp2px(20)), movieName.length() + 1, movieName
            .length() + 1 + country.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
    style.setSpan(new AlignmentSpan.Standard(Layout.Alignment.ALIGN_CENTER), 0, movieName
            .length() + 1 + country.length(), Spanned
            .SPAN_EXCLUSIVE_INCLUSIVE);
    style.setSpan(new AbsoluteSizeSpan(SystemUtil.dp2px(16)), movieName.length() + country
            .length() + 3, content.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);

    mTvMovieContent.setText(style);
}
 
開發者ID:4FunApp,項目名稱:4Fun,代碼行數:21,代碼來源:MovieDetailActivity.java

示例8: openAlignment

import android.text.style.AlignmentSpan; //導入依賴的package包/類
private void openAlignment(final Layout.Alignment alignment, Editable output) {
    output.append("\n"); // new paragraph before aligment span!
    int len = output.length();
    AlignmentSpan span;
    switch (alignment) {
        case ALIGN_OPPOSITE:
            span = new OppositeAlignment();
            break;
        case ALIGN_CENTER:
            span = new CenterAlignment();
            break;
        default:
            return;
    }
    output.setSpan(span, len, len, Spanned.SPAN_MARK_MARK);
    mAlignmentStack.add(0, alignment);
}
 
開發者ID:suwhs,項目名稱:wATLlib,代碼行數:18,代碼來源:HtmlTagHandler.java

示例9: handleTag

import android.text.style.AlignmentSpan; //導入依賴的package包/類
@Override
protected void handleTag(boolean opening, String tag, Map<String, String> attrs, Editable output) {
    if ("span".equalsIgnoreCase(tag)) {
        if (opening) {
            Span mark = null;
            if ("center".equalsIgnoreCase(attrs.get("class"))) {
                mark = new Center();
                handleP(output);
                start(output, mark);
            }
            spanStack.add(mark);
        } else {
            // Remove.
            Object repl = null;
            Class<? extends Span> kind = Span.class;
            Span span = spanStack.remove(spanStack.size() - 1);
            if (span instanceof Center) {
                handleP(output);
                kind = Center.class;
                repl = new AlignmentSpan.Standard(Layout.Alignment.ALIGN_CENTER);
            }
            end(output, kind, repl);
        }
    }
}
 
開發者ID:labhackercd,項目名稱:edm,代碼行數:26,代碼來源:MessageTagHandler.java

示例10: showPIN

import android.text.style.AlignmentSpan; //導入依賴的package包/類
@Override
public void showPIN(final String pin) {
    RingApplication.uiHandler.post(() -> {
        mWaitDialog.dismiss();
        String pined = getString(R.string.account_end_export_infos).replace("%%", pin);
        final SpannableString styledResultText = new SpannableString(pined);
        int pos = pined.lastIndexOf(pin);
        styledResultText.setSpan(new AlignmentSpan.Standard(Layout.Alignment.ALIGN_CENTER), pos, (pos + pin.length()), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        styledResultText.setSpan(new StyleSpan(Typeface.BOLD), pos, (pos + pin.length()), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        styledResultText.setSpan(new RelativeSizeSpan(2.8f), pos, (pos + pin.length()), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

        new AlertDialog.Builder(getActivity())
                .setMessage(styledResultText)
                .setPositiveButton(android.R.string.ok, (dialog, which) -> getFragmentManager().popBackStack())
                .show();
    });
}
 
開發者ID:savoirfairelinux,項目名稱:ring-client-android,代碼行數:18,代碼來源:TVAccountExport.java

示例11: showPIN

import android.text.style.AlignmentSpan; //導入依賴的package包/類
@Override
public void showPIN(final String pin) {
    RingApplication.uiHandler.post(() -> {
        hideWizard();
        mWaitDialog.dismiss();
        mLinkAccountView.setVisibility(View.VISIBLE);
        mPasswordLayout.setVisibility(View.GONE);
        mEndBtn.setVisibility(View.VISIBLE);
        mStartBtn.setVisibility(View.GONE);

        String pined = getString(R.string.account_end_export_infos).replace("%%", pin);
        final SpannableString styledResultText = new SpannableString(pined);
        int pos = pined.lastIndexOf(pin);
        styledResultText.setSpan(new AlignmentSpan.Standard(Layout.Alignment.ALIGN_CENTER), pos, (pos + pin.length()), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        styledResultText.setSpan(new StyleSpan(Typeface.BOLD), pos, (pos + pin.length()), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        styledResultText.setSpan(new RelativeSizeSpan(2.8f), pos, (pos + pin.length()), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        mExportInfos.setText(styledResultText);
        mExportInfos.requestFocus();

        KeyboardVisibilityManager.hideKeyboard(getActivity(), 0);
    });
}
 
開發者ID:savoirfairelinux,項目名稱:ring-client-android,代碼行數:23,代碼來源:RingAccountSummaryFragment.java

示例12: addEndTag

import android.text.style.AlignmentSpan; //導入依賴的package包/類
private Spannable addEndTag(SpannableStringBuilder builder) {
	
	//Don't add the tag to the last section.
	Spine spine = bookView.getSpine();
	
	if (spine == null || spine.getPosition() >= spine.size() -1 ) {
		return builder;
	}
	
	int length = builder.length();
	builder.append("\uFFFC");
	builder.append("\n");
	builder.append( context.getString(R.string.end_of_section));
	//If not, consider it an internal nav link.			
	ClickableSpan span = new ClickableSpan() {
			
		@Override
		public void onClick(View widget) {
			pageDown();					
		}
	};

	Drawable img = context.getResources().getDrawable(R.drawable.gateway);
	img.setBounds(0, 0, img.getIntrinsicWidth(), img.getIntrinsicHeight() );
	builder.setSpan(new ImageSpan(img), length, length+1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
	builder.setSpan(span, length, builder.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

       builder.setSpan( (AlignmentSpan) () -> Alignment.ALIGN_CENTER
		, length, builder.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

	return builder;		
}
 
開發者ID:ceji-longquan,項目名稱:ceji_android,代碼行數:33,代碼來源:ScrollingStrategy.java

示例13: align_start_should_add_only_one_span

import android.text.style.AlignmentSpan; //導入依賴的package包/類
@Test
public void align_start_should_add_only_one_span() {
    spanBuilder.alignStart(paragraph)
               .apply();

    verify((SpanEZ) spanBuilder, times(1))
            .addSpan(isA(TargetRange.class), isA(AlignmentSpan.class));
}
 
開發者ID:yombunker,項目名稱:SpanEZ,代碼行數:9,代碼來源:SpanEZTest.java

示例14: align_center_should_add_only_one_span

import android.text.style.AlignmentSpan; //導入依賴的package包/類
@Test
public void align_center_should_add_only_one_span() {
    spanBuilder.alignCenter(paragraph)
               .apply();

    verify((SpanEZ) spanBuilder, times(1))
            .addSpan(isA(TargetRange.class), isA(AlignmentSpan.class));
}
 
開發者ID:yombunker,項目名稱:SpanEZ,代碼行數:9,代碼來源:SpanEZTest.java

示例15: align_end_should_add_only_one_span

import android.text.style.AlignmentSpan; //導入依賴的package包/類
@Test
public void align_end_should_add_only_one_span() {
    spanBuilder.alignEnd(paragraph)
               .apply();

    verify((SpanEZ) spanBuilder, times(1))
            .addSpan(isA(TargetRange.class), isA(AlignmentSpan.class));
}
 
開發者ID:yombunker,項目名稱:SpanEZ,代碼行數:9,代碼來源:SpanEZTest.java


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