当前位置: 首页>>代码示例>>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;未经允许,请勿转载。