Java Code Examples for android.widget.TextView.setTextSize()

The following are Jave code examples for showing how to use setTextSize() of the android.widget.TextView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: GongXianSheng   File: OrderDetailActivity.java   View Source Code Vote up 7 votes
private void setUpReturnOrderView(ReturnOrderDetailResponse returnOrderDetailResponse) {
        TextView tv = new TextView(getActivityContext());
        tv.setTextSize(14);
        tv.setTextColor(Color.parseColor(getString(R.string.textColorThird)));
        tv.setGravity(Gravity.CENTER_VERTICAL);
        tv.setTag(returnOrderDetailResponse.getReturnOrder().getReturnOrderID());
        if (!TextUtils.isEmpty(returnOrderDetailResponse.getReturnOrder().getName())) {
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                    CommonUtils.dip2px(getActivityContext(), 40));
            SpannableString ss = new SpannableString(getString(R.string.tag_return_order_num) + returnOrderDetailResponse.getReturnOrder().getName());
            ss.setSpan(new ForegroundColorSpan(Color.parseColor(getString(R.string.color_return_order_num))), 5, 5 + returnOrderDetailResponse.getReturnOrder().getName().length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
            tv.setText(ss);
            mLlReturn.addView(tv, params);
            tv.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    //跳转到退货单详情
//                    Intent intent = new Intent(mContext, ReturnDetailActivity.class);
//                    intent.putExtra("rid", returnId);
//                    startActivity(intent);
                }
            });
        }
    }
 
Example 2
Project: YCDialog   File: DialogAdapter.java   View Source Code Vote up 6 votes
LeftHolder(View view) {
    super(view);

    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);

    view.setLayoutParams(params);
    item = new TextView(view.getContext());
    item.setLayoutParams(params);
    item.setMaxLines(1);
    item.setEllipsize(TextUtils.TruncateAt.END);
    item.setGravity(Gravity.CENTER_VERTICAL);
    item.setTextColor(ContextCompat.getColor(view.getContext(), R.color.gray_black));
    item.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getResources().getDimension(R.dimen.app_normal_margin));
    item.setCompoundDrawablePadding(leftPadding);
    item.setPadding(padding, padding, padding, padding);

    TypedValue typedValue = new TypedValue();
    view.getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, typedValue, true);
    item.setBackgroundResource(typedValue.resourceId);

    ((LinearLayout) view).addView(item);
}
 
Example 3
Project: RLibrary   File: UIItemDialog.java   View Source Code Vote up 6 votes
protected View createItem(final ItemInfo info) {
    TextView textView = new TextView(mActivity);
    textView.setText(info.mItemText);
    textView.setTextColor(SkinHelper.getSkin().getThemeSubColor());
    textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, SkinHelper.getSkin().getMainTextSize());
    textView.setGravity(Gravity.CENTER);
    if (info.mClickListener instanceof RClickListener) {
        textView.setOnClickListener(info.mClickListener);
    } else {
        textView.setOnClickListener(new RClickListener(1000) {
            @Override
            public void onRClick(View view) {
                info.mClickListener.onClick(view);
                if (info.autoCloseDialog) {
                    finishDialog();
                }
            }
        });
    }
    return textView;
}
 
Example 4
Project: GitHub   File: SegmentTabLayout.java   View Source Code Vote up 6 votes
private void updateTabStyles() {
        for (int i = 0; i < mTabCount; i++) {
            View tabView = mTabsContainer.getChildAt(i);
            tabView.setPadding((int) mTabPadding, 0, (int) mTabPadding, 0);
            TextView tv_tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title);
            tv_tab_title.setTextColor(i == mCurrentTab ? mTextSelectColor : mTextUnselectColor);
            tv_tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextsize);
//            tv_tab_title.setPadding((int) mTabPadding, 0, (int) mTabPadding, 0);
            if (mTextAllCaps) {
                tv_tab_title.setText(tv_tab_title.getText().toString().toUpperCase());
            }

            if (mTextBold == TEXT_BOLD_BOTH) {
                tv_tab_title.getPaint().setFakeBoldText(true);
            } else if (mTextBold == TEXT_BOLD_NONE) {
                tv_tab_title.getPaint().setFakeBoldText(false);
            }
        }
    }
 
Example 5
Project: springreplugin   File: ThemeDialogActivity.java   View Source Code Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout root = new LinearLayout(this);
    root.setPadding(30, 30, 30, 30);
    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT);
    root.setLayoutParams(lp);

    setContentView(root);

    // textView
    TextView textView = new TextView(this);
    textView.setText("Theme: Dialog");
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(30);
    LinearLayout.LayoutParams lp2 = new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT);
    textView.setLayoutParams(lp2);
    root.addView(textView);
}
 
Example 6
Project: Android-GuideView   File: MainActivity.java   View Source Code Vote up 5 votes
private TextView createTextView() {
    TextView textView = new TextView(this);
    textView.setLayoutParams(new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    textView.setTextColor(Color.CYAN);
    textView.setTextSize(30f);
    textView.setBackgroundColor(Color.RED);
    textView.setText("tips view");
    return textView;
}
 
Example 7
Project: Elements   File: Presenter.java   View Source Code Vote up 5 votes
@Override
protected void onBindView(Pager.Page page, Holder holder, Element element) {
    super.onBindView(page, holder, element);
    String text = (String) element.getData();
    TextView view = (TextView) holder.getRoot();
    view.setText(text);
    int size, textColor, bgColor;
    switch (element.getElementType()) {
        case TYPE_TEXT_SMALL:
            size = 16;
            textColor = Color.GRAY;
            bgColor = Color.TRANSPARENT;
            break;
        case TYPE_TEXT_MESSAGE:
            size = 18;
            textColor = Color.WHITE;
            bgColor = ContextCompat.getColor(getContext(), R.color.colorAccent);
            // textColor = Color.DKGRAY;
            // bgColor = Color.WHITE;
            break;
        case TYPE_TEXT_LARGE:
        default:
            size = 22;
            textColor = Color.BLACK;
            bgColor = Color.TRANSPARENT;
            break;
    }
    view.setTextSize(size);
    view.setTextColor(textColor);
    view.setBackgroundColor(bgColor);

}
 
Example 8
Project: QMUI_Android   File: QMUIDialogBlockBuilder.java   View Source Code Vote up 5 votes
@Override
protected void onCreateContent(QMUIDialog dialog, ViewGroup parent) {
    TextView contentTv = new TextView(mContext);
    contentTv.setTextColor(QMUIResHelper.getAttrColor(mContext, R.attr.qmui_config_color_gray_4));
    contentTv.setText(mContent);
    contentTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, QMUIResHelper.getAttrDimen(mContext, R.attr.qmui_dialog_block_content_text_size));
    contentTv.setLineSpacing(QMUIDisplayHelper.dpToPx(2), 1.0f);
    contentTv.setPadding(
            QMUIResHelper.getAttrDimen(mContext, R.attr.qmui_dialog_padding_horizontal),
            QMUIResHelper.getAttrDimen(mContext, hasTitle() ? R.attr.qmui_dialog_content_padding_top : R.attr.qmui_dialog_content_padding_top_when_no_title),
            QMUIResHelper.getAttrDimen(mContext, R.attr.qmui_dialog_padding_horizontal),
            QMUIResHelper.getAttrDimen(mContext, R.attr.qmui_dialog_content_padding_bottom_when_action_block)
    );
    parent.addView(contentTv);
}
 
Example 9
Project: GitHub   File: IndicatorView.java   View Source Code Vote up 5 votes
/**
 * 向父容器中添加TextView
 *
 * @param text  TextView显示文字
 * @param color TextView的背景颜色,如:"#FADBCC"
 */
private void addTextView(Context context, String text, int color) {
    TextView textView = new TextView(context);
    textView.setBackgroundColor(color);
    textView.setText(text);
    textView.setTextColor(textColor);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
    textView.setSingleLine();
    textView.setGravity(Gravity.CENTER);
    textView.setLayoutParams(new LayoutParams(0, LayoutParams.WRAP_CONTENT, 1.0F));
    this.addView(textView);
}
 
Example 10
Project: lqrwechatrongcloud   File: EditPagePort.java   View Source Code Vote up 5 votes
private void initBottom(LinearLayout llBottom, float ratio) {
	LinearLayout llAt = new LinearLayout(activity);
	llAt.setPadding(0, 0, 0, 5);
	llAt.setBackgroundColor(0xffffffff);
	int bottomHeight = (int) (DESIGN_BOTTOM_HEIGHT * ratio);
	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, bottomHeight);
	llBottom.addView(llAt, lp);

	tvAt = new TextView(activity);
	tvAt.setTextColor(0xff3b3b3b);
	tvAt.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
	tvAt.setGravity(Gravity.BOTTOM);
	tvAt.setText("@");
	int padding = (int) (DESIGN_LEFT_PADDING * ratio);
	tvAt.setPadding(padding, 0, padding, 0);
	lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	llAt.addView(tvAt, lp);
	tvAt.setOnClickListener(this);
	if (isShowAtUserLayout(platform.getName())) {
		tvAt.setVisibility(View.VISIBLE);
	} else {
		tvAt.setVisibility(View.INVISIBLE);
	}

	tvTextCouter = new TextView(activity);
	tvTextCouter.setTextColor(0xff3b3b3b);
	tvTextCouter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21);
	tvTextCouter.setGravity(Gravity.BOTTOM | Gravity.RIGHT);
	onTextChanged(etContent.getText(), 0, 0, 0);
	tvTextCouter.setPadding(padding, 0, padding, 0);
	lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	lp.weight = 1;
	llAt.addView(tvTextCouter, lp);

	View v = new View(activity);
	v.setBackgroundColor(0xffcccccc);
	int px1 = ratio > 1 ? ((int) ratio) : 1;
	lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, px1);
	llBottom.addView(v, lp);
}
 
Example 11
Project: androidgithub   File: PRTHeader.java   View Source Code Vote up 5 votes
public PRTHeader(Context context) {
	super(context);
	int[] size = R.getScreenSize(context);
	float screenWidth = size[0] < size[1] ? size[0] : size[1];
	float ratio = screenWidth / DESIGN_SCREEN_WIDTH;

	setOrientation(VERTICAL);

	LinearLayout llInner = new LinearLayout(context);
	LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lp.gravity = Gravity.CENTER_HORIZONTAL;
	addView(llInner, lp);

	ivArrow = new RotateImageView(context);
	int resId = R.getBitmapRes(context, "ssdk_oks_ptr_ptr");
	if (resId > 0) {
		ivArrow.setImageResource(resId);
	}
	int avatarWidth = (int) (ratio * DESIGN_AVATAR_WIDTH);
	lp = new LayoutParams(avatarWidth, avatarWidth);
	lp.gravity = Gravity.CENTER_VERTICAL;
	int avataPadding = (int) (ratio * DESIGN_AVATAR_PADDING);
	lp.topMargin = lp.bottomMargin = avataPadding;
	llInner.addView(ivArrow, lp);

	pbRefreshing = new ProgressBar(context);
	resId = R.getBitmapRes(context, "ssdk_oks_classic_progressbar");
	Drawable pbdrawable = context.getResources().getDrawable(resId);
	pbRefreshing.setIndeterminateDrawable(pbdrawable);
	llInner.addView(pbRefreshing, lp);
	pbRefreshing.setVisibility(View.GONE);

	tvHeader = new TextView(getContext());
	tvHeader.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
	tvHeader.setPadding(avataPadding, 0, avataPadding, 0);
	tvHeader.setTextColor(0xff09bb07);
	lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lp.gravity = Gravity.CENTER_VERTICAL;
	llInner.addView(tvHeader, lp);
}
 
Example 12
Project: KrGallery   File: PhotoPickerAlbumsCell.java   View Source Code Vote up 5 votes
public AlbumView(Context context) {
    super(context);

    imageView = new BackupImageView(context);
    addView(imageView,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);
    linearLayout.setBackgroundColor(0x7f000000);
    addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 28,
            Gravity.LEFT | Gravity.BOTTOM));

    nameTextView = new TextView(context);
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    nameTextView.setTextColor(0xffffffff);
    nameTextView.setSingleLine(true);
    nameTextView.setEllipsize(TextUtils.TruncateAt.END);
    nameTextView.setMaxLines(1);
    nameTextView.setGravity(Gravity.CENTER_VERTICAL);
    linearLayout.addView(nameTextView,
            LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, 8, 0, 0, 0));

    countTextView = new TextView(context);
    countTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    countTextView.setTextColor(0xffaaaaaa);
    countTextView.setSingleLine(true);
    countTextView.setEllipsize(TextUtils.TruncateAt.END);
    countTextView.setMaxLines(1);
    countTextView.setGravity(Gravity.CENTER_VERTICAL);
    linearLayout.addView(countTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT,
            LayoutHelper.MATCH_PARENT, 4, 0, 4, 0));

    selector = new View(context);
    selector.setBackgroundResource(R.drawable.list_selector);
    addView(selector,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
}
 
Example 13
Project: ShaddockVideoPlayer   File: IjkVideoView.java   View Source Code Vote up 5 votes
private void initVideoView(Context context) {
    mAppContext = context.getApplicationContext();
    mSettings = new Settings(mAppContext);

    initBackground();
    initRenders();

    mVideoWidth = 0;
    mVideoHeight = 0;
    // REMOVED: getHolder().addCallback(mSHCallback);
    // REMOVED: getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    setFocusable(true);
    setFocusableInTouchMode(true);
    requestFocus();
    // REMOVED: mPendingSubtitleTracks = new Vector<Pair<InputStream, MediaFormat>>();
    mCurrentState = STATE_IDLE;
    mTargetState = STATE_IDLE;

    subtitleDisplay = new TextView(context);
    subtitleDisplay.setTextSize(24);
    subtitleDisplay.setGravity(Gravity.CENTER);
    LayoutParams layoutParams_txt = new LayoutParams(
            LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT,
            Gravity.BOTTOM);
    addView(subtitleDisplay, layoutParams_txt);
}
 
Example 14
Project: ShortcutMenu   File: ToastUtil.java   View Source Code Vote up 4 votes
private static void setTextSize(Toast toast) {
    TextView view = getTextView(toast);
    Context context=view.getContext();
    int size = context.getResources().getDimensionPixelSize(R.dimen.text_size_middle2);
    view.setTextSize(TypedValue.COMPLEX_UNIT_PX,ScreenUtil.getScalePxValue(size));
}
 
Example 15
Project: androidgithub   File: FriendListPage.java   View Source Code Vote up 4 votes
private void initTitle(RelativeLayout rlTitle, float ratio) {
	tvCancel = new TextView(activity);
	tvCancel.setTextColor(0xff3b3b3b);
	tvCancel.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
	tvCancel.setGravity(Gravity.CENTER);
	int resId = R.getStringRes(activity, "ssdk_oks_cancel");
	if (resId > 0) {
		tvCancel.setText(resId);
	}
	int padding = (int) (DESIGN_LEFT_PADDING * ratio);
	tvCancel.setPadding(padding, 0, padding, 0);
	RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	rlTitle.addView(tvCancel, lp);
	tvCancel.setOnClickListener(this);

	TextView tvTitle = new TextView(activity);
	tvTitle.setTextColor(0xff3b3b3b);
	tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
	tvTitle.setGravity(Gravity.CENTER);
	resId = R.getStringRes(activity, "ssdk_oks_contacts");
	if (resId > 0) {
		tvTitle.setText(resId);
	}
	lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	lp.addRule(RelativeLayout.CENTER_IN_PARENT);
	rlTitle.addView(tvTitle, lp);

	tvConfirm = new TextView(activity);
	tvConfirm.setTextColor(0xffff6d11);
	tvConfirm.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
	tvConfirm.setGravity(Gravity.CENTER);
	resId = R.getStringRes(activity, "ssdk_oks_confirm");
	if (resId > 0) {
		tvConfirm.setText(resId);
	}
	tvConfirm.setPadding(padding, 0, padding, 0);
	lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
	rlTitle.addView(tvConfirm, lp);
	tvConfirm.setOnClickListener(this);
}
 
Example 16
Project: PageScrollView   File: PageScrollTab.java   View Source Code Vote up 4 votes
private void updateTabStyles() {
    int itemCount = getChildCount();
    boolean hasMutiBackground = mItemBackgroundFirst != 0 && mItemBackgroundLast != 0;
    for (int i = 0; i < itemCount; i++) {
        int backgroundRes = mItemBackground;
        View v = getChildAt(i);
        if (hasMutiBackground) {
            if (i == 0) {
                if (itemCount == 1) {
                    if (mItemBackgroundFull != 0) {
                        backgroundRes = mItemBackgroundFull;
                    }
                } else {
                    backgroundRes = mItemBackgroundFirst;
                }
            } else if (i == itemCount - 1) {
                backgroundRes = mItemBackgroundLast;
            }
        }
        if (backgroundRes != 0) {
            v.setBackgroundResource(backgroundRes);
        }
        if (v instanceof TextView) {
            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);
            tab.setTypeface(mTextTypeFace, mTextTypefaceStyle);
            if (mTextColorResId != 0) {
                tab.setTextColor(getContext().getResources().getColorStateList(mTextColorResId));
            } else {
                tab.setTextColor(mTextColor);
            }
            // setAllCaps() is only available from API 14, so the upper case
            // is made manually if we are on a
            // pre-ICS-build
            if (mTextAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(mLocalInfo));
                }
            }
        }
    }
}
 
Example 17
Project: aos-Video   File: SubtitleSettingsDialog.java   View Source Code Vote up 4 votes
private void init(Context context, final SubtitleManager stm) {
    mSubtitleManager = stm;
    mSize = stm.getSize();
    mColor = stm.getColor();
    setIcon(R.drawable.ic_menu_settings);

    getWindow().setGravity(Gravity.TOP);
    getWindow().setBackgroundDrawable(new ColorDrawable(VideoInfoCommonClass.getAlphaColor(ContextCompat.getColor(context, R.color.background_material_dark),128)));
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);

    final LayoutInflater inflater =
            (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    final LinearLayout view = (LinearLayout) inflater.inflate(R.layout.subtitle_settings_dialog, null);

    ((SubtitleColorPicker)view.findViewById(R.id.color_layout)).setColorPickListener(this);



    setView(view);
    mLeftSizeButton = view.findViewById(R.id.left_a);
    mLeftSizeButton.setOnTouchListener(this);
    mRightSizeButton = view.findViewById(R.id.right_a);
    mRightSizeButton.setOnTouchListener(this);

    mRightVerticalButton = view.findViewById(R.id.right_icon);
    mRightVerticalButton.setOnTouchListener(this);
    mLeftVerticalButton = view.findViewById(R.id.left_icon);
    mLeftVerticalButton.setOnTouchListener(this);

    mSampleText = (TextView) view.findViewById(R.id.subtitle_sample_text);
    mSampleText.setTextSize(mSize);
    mSampleText.setTextColor(mColor);
    mSizeSeekBar = (SeekBar) view.findViewById(R.id.subtitle_size_seekbar);
    mSizeSeekBar.setOnSeekBarChangeListener(this);

    mVertSeekBar = (SeekBar) view.findViewById(R.id.subtitle_vert_seekbar);
    // 0.255 Range is what SubtitleManager.setVerticalPosition() expects
    mVertSeekBar.setMax(255);
    mVertSeekBar.setOnSeekBarChangeListener(this);

    setCancelable(true);
    setCanceledOnTouchOutside(true);

    mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
}
 
Example 18
Project: PlusGram   File: DrawerProfileCell.java   View Source Code Vote up 4 votes
public DrawerProfileCell(Context context) {
    super(context);
    setBackgroundColor(Theme.ACTION_BAR_PROFILE_COLOR);


    shadowView = new ImageView(context);
    shadowView.setVisibility(INVISIBLE);
    shadowView.setScaleType(ImageView.ScaleType.FIT_XY);
    shadowView.setImageResource(R.drawable.bottom_shadow);
    addView(shadowView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 70, Gravity.LEFT | Gravity.BOTTOM));
    SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
    avatarImageView = new BackupImageView(context);
    avatarImageView.getImageReceiver().setRoundRadius(AndroidUtilities.dp(32));

    int aSize = themePrefs.getInt("drawerAvatarSize", 64);
    boolean centerAvatar = themePrefs.getBoolean("drawerCenterAvatarCheck", false);
    if(!centerAvatar){
        addView(avatarImageView, LayoutHelper.createFrame(aSize, aSize, Gravity.LEFT | Gravity.BOTTOM, 16, 0, 0, 67));
    }else{
        addView(avatarImageView, LayoutHelper.createFrame(aSize, aSize, Gravity.CENTER | Gravity.BOTTOM, 0, 0, 0, 67));
    }


    final Activity activity = (Activity) context;

    avatarImageView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (activity == null) {
                return;
            }
            TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId());
            if (user.photo != null && user.photo.photo_big != null) {
                PhotoViewer.getInstance().setParentActivity(activity);
                PhotoViewer.getInstance().openPhoto(user.photo.photo_big, DrawerProfileCell.this);
            }
        }
    });
    nameTextView = new TextView(context);
    nameTextView.setTextColor(0xffffffff);
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    nameTextView.setLines(1);
    nameTextView.setMaxLines(1);
    nameTextView.setSingleLine(true);
    if(!centerAvatar){
        nameTextView.setGravity(Gravity.LEFT);
    nameTextView.setEllipsize(TextUtils.TruncateAt.END);
        addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM, 16, 0, 16, 28));
    }else{
        nameTextView.setGravity(Gravity.CENTER);
        addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER | Gravity.BOTTOM, 0, 0, 0, 28));
    }

    phoneTextView = new TextView(context);
    phoneTextView.setTextColor(0xffc2e5ff);
    phoneTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    phoneTextView.setLines(1);
    phoneTextView.setMaxLines(1);
    phoneTextView.setSingleLine(true);
    if(!centerAvatar){
        phoneTextView.setGravity(Gravity.LEFT);
        addView(phoneTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM, 16, 0, 16, 9));
    }else{
        phoneTextView.setGravity(Gravity.CENTER);
        addView(phoneTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER | Gravity.BOTTOM, 0, 0, 0, 9));
    }


    cloudView = new CloudView(context);
    addView(cloudView, LayoutHelper.createFrame(61, 61, Gravity.RIGHT | Gravity.BOTTOM));
}
 
Example 19
Project: XinFramework   File: CommonTitleBar.java   View Source Code Vote up 4 votes
/**
 * 初始化主视图右边部分
 *
 * @param context
 */
private void initMainRightViews(Context context) {
    LayoutParams rightInnerParams = new LayoutParams(WRAP_CONTENT, MATCH_PARENT);
    rightInnerParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    rightInnerParams.addRule(RelativeLayout.CENTER_VERTICAL);

    if (rightType == TYPE_RIGHT_TEXTVIEW) {
        // 初始化右边TextView
        tvRight = new TextView(context);
        tvRight.setId(ViewFinder.generateViewId());
        tvRight.setText(rightText);
        tvRight.setTextColor(rightTextColor);
        tvRight.setTextSize(TypedValue.COMPLEX_UNIT_PX, rightTextSize);
        tvRight.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
        tvRight.setSingleLine(true);
        tvRight.setPadding(PADDING_15, 0, PADDING_15, 0);
        tvRight.setOnClickListener(this);
        rlMain.addView(tvRight, rightInnerParams);
        mFadeViewList.add(tvRight);
    } else if (rightType == TYPE_RIGHT_IMAGEBUTTON) {
        // 初始化右边ImageBtn
        btnRight = new ImageButton(context);
        btnRight.setId(ViewFinder.generateViewId());
        btnRight.setImageResource(rightImageResource);
        btnRight.setBackgroundColor(Color.TRANSPARENT);
        btnRight.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        btnRight.setPadding(PADDING_15, 0, PADDING_15, 0);
        btnRight.setOnClickListener(this);
        rlMain.addView(btnRight, rightInnerParams);
        mFadeViewList.add(btnRight);
    } else if (rightType == TYPE_RIGHT_CUSTOM_VIEW) {
        // 初始化自定义view
        viewCustomRight = LayoutInflater.from(context).inflate(rightCustomViewRes, null);
        if (viewCustomRight.getId() == 0) {
            viewCustomRight.setId(ViewFinder.generateViewId());
        }
        rlMain.addView(viewCustomRight, rightInnerParams);

        mFadeViewList.add(viewCustomRight);
    }
}
 
Example 20
Project: GitHub   File: TextSizeEnterSharedElementCallback.java   View Source Code Vote up 3 votes
@Override
public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements,
    List<View> sharedElementSnapshots) {

  TextView textView = findTextView(sharedElements);

  // Setup the TextView's end values.
  textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mEndTextSize);

}