Java Code Examples for android.widget.TextView#setIncludeFontPadding()

The following examples show how to use android.widget.TextView#setIncludeFontPadding() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebFragment.java    From PowerFileExplorer with GNU General Public License v3.0 6 votes vote down vote up
protected void updateChildTextView(ViewGroup viewGroup) {
	if (viewGroup == null || viewGroup.getChildCount() == 0) return;

	for (int i = 0; i < viewGroup.getChildCount(); i++) {
		View view = viewGroup.getChildAt(i);
		if (view instanceof TextView) {
			TextView textView = (TextView) view;
			textView.setTextColor(titleColor);
			textView.setTypeface(TypefaceHelper.get(context, titleFont));
			textView.setLineSpacing(0, 1.1f);
			textView.setIncludeFontPadding(false);
		}

		if (view instanceof ViewGroup) updateChildTextView((ViewGroup) view);
	}
}
 
Example 2
Source File: ListItemView.java    From ListItemView with Apache License 2.0 6 votes vote down vote up
private void setupTextView(final TextView textView, final int leading, final int step) {
    // This is to make the behavior more deterministic: remove extra top/bottom padding
    textView.setIncludeFontPadding(false);

    // Get font metrics and calculate required inter-line extra
    Paint.FontMetricsInt metrics = textView.getPaint().getFontMetricsInt();
    final int extra = leading - metrics.descent + metrics.ascent;
    textView.setLineSpacing(extra, 1);

    // Determine minimum required top extra so that the view lands on the grid
    final int alignTopExtra = (step + metrics.ascent % step) % step;
    // Determine minimum required bottom extra so that view bounds are aligned with the grid
    final int alignBottomExtra = (step - metrics.descent % step) % step;

    textView.setPadding(textView.getPaddingLeft(), textView.getPaddingTop() + alignTopExtra,
            textView.getPaddingRight(), textView.getPaddingBottom() + alignBottomExtra);
}
 
Example 3
Source File: XPreference.java    From android-project-wo2b with Apache License 2.0 6 votes vote down vote up
public void addHintIcon(int drawableId)
{
	if (this.mHintIconArray.indexOfKey(drawableId) == -1)
	{
		this.mHintIconArray.put(drawableId, drawableId);
		
		TextView tv = new TextView(mContext);
		tv.setTag(drawableId);
		tv.setGravity(Gravity.CENTER);
		ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
				ViewGroup.LayoutParams.WRAP_CONTENT);
		tv.setLayoutParams(lp);
		tv.setBackgroundResource(drawableId);
		tv.setIncludeFontPadding(false);
		
		this.mHintIcons.addView(tv);
	}
}
 
Example 4
Source File: XPreferenceGreen.java    From android-project-wo2b with Apache License 2.0 6 votes vote down vote up
public void addHintIcon(int drawableId)
{
	if (this.mHintIconArray.indexOfKey(drawableId) == -1)
	{
		this.mHintIconArray.put(drawableId, drawableId);
		
		TextView tv = new TextView(mContext);
		tv.setTag(drawableId);
		tv.setGravity(Gravity.CENTER);
		ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
				ViewGroup.LayoutParams.WRAP_CONTENT);
		tv.setLayoutParams(lp);
		tv.setBackgroundResource(drawableId);
		tv.setIncludeFontPadding(false);
		
		this.mHintIcons.addView(tv);
	}
}
 
Example 5
Source File: D.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
private void a()
{
    b = new TextView(TaskGuide.m(a));
    b.setTextColor(Color.rgb(255, 255, 255));
    b.setTextSize(15F);
    b.setShadowLayer(1.0F, 1.0F, 1.0F, Color.rgb(242, 211, 199));
    b.setGravity(3);
    b.setEllipsize(android.text.TextUtils.TruncateAt.END);
    b.setIncludeFontPadding(false);
    b.setSingleLine(true);
    android.widget.LinearLayout.LayoutParams layoutparams = new android.widget.LinearLayout.LayoutParams(0, -2);
    layoutparams.weight = 1.0F;
    layoutparams.leftMargin = TaskGuide.d(a, 4);
    addView(b, layoutparams);
    c = new Button(TaskGuide.n(a));
    c.setPadding(0, 0, 0, 0);
    c.setTextSize(16F);
    c.setTextColor(Color.rgb(255, 255, 255));
    c.setShadowLayer(1.0F, 1.0F, 1.0F, Color.rgb(242, 211, 199));
    c.setIncludeFontPadding(false);
    c.setOnClickListener(new B(a, d.a));
    android.widget.LinearLayout.LayoutParams layoutparams1 = new android.widget.LinearLayout.LayoutParams(TaskGuide.d(a, TaskGuide.a()), TaskGuide.d(a, TaskGuide.c()));
    layoutparams1.leftMargin = TaskGuide.d(a, 2);
    layoutparams1.rightMargin = TaskGuide.d(a, 8);
    addView(c, layoutparams1);
}
 
Example 6
Source File: WheelItem.java    From tysq-android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 初始化
 */
private void init() {
    LinearLayout layout = new LinearLayout(getContext());
    LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, WheelUtils.dip2px(getContext(),
            WheelConstants
                    .WHEEL_ITEM_HEIGHT));
    layout.setOrientation(LinearLayout.HORIZONTAL);
    layout.setPadding(WheelConstants.WHEEL_ITEM_PADDING, WheelConstants.WHEEL_ITEM_PADDING, WheelConstants
            .WHEEL_ITEM_PADDING, WheelConstants.WHEEL_ITEM_PADDING);
    layout.setGravity(Gravity.CENTER);
    addView(layout, layoutParams);

    // 图片
    mImage = new ImageView(getContext());
    mImage.setTag(WheelConstants.WHEEL_ITEM_IMAGE_TAG);
    mImage.setVisibility(View.GONE);
    LayoutParams imageParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    imageParams.rightMargin = WheelConstants.WHEEL_ITEM_MARGIN;
    layout.addView(mImage, imageParams);

    // 文本
    mText = new TextView(getContext());
    mText.setTag(WheelConstants.WHEEL_ITEM_TEXT_TAG);
    mText.setEllipsize(TextUtils.TruncateAt.END);
    mText.setSingleLine();
    mText.setIncludeFontPadding(false);
    mText.setGravity(Gravity.CENTER);
    mText.setTextColor(Color.BLACK);
    LayoutParams textParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    layout.addView(mText, textParams);
}
 
Example 7
Source File: WheelItem.java    From WheelView with Apache License 2.0 5 votes vote down vote up
/**
 * 初始化
 */
private void init() {
    LinearLayout layout = new LinearLayout(getContext());
    LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT,
            WheelUtils.dip2px(getContext(),
            WheelConstants
                    .WHEEL_ITEM_HEIGHT));
    layout.setOrientation(LinearLayout.HORIZONTAL);
    layout.setPadding(WheelConstants.WHEEL_ITEM_PADDING, WheelConstants.WHEEL_ITEM_PADDING,
            WheelConstants
            .WHEEL_ITEM_PADDING, WheelConstants.WHEEL_ITEM_PADDING);
    layout.setGravity(Gravity.CENTER);
    addView(layout, layoutParams);

    // 图片
    mImage = new ImageView(getContext());
    mImage.setTag(WheelConstants.WHEEL_ITEM_IMAGE_TAG);
    mImage.setVisibility(View.GONE);
    LayoutParams imageParams = new LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    imageParams.rightMargin = WheelConstants.WHEEL_ITEM_MARGIN;
    layout.addView(mImage, imageParams);

    // 文本
    mText = new TextView(getContext());
    mText.setTag(WheelConstants.WHEEL_ITEM_TEXT_TAG);
    mText.setEllipsize(TextUtils.TruncateAt.END);
    mText.setSingleLine();
    mText.setIncludeFontPadding(false);
    mText.setGravity(Gravity.CENTER);
    mText.setTextColor(Color.BLACK);
    LayoutParams textParams = new LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT);
    layout.addView(mText, textParams);
}
 
Example 8
Source File: PlatformGridView.java    From -Android_ShareSDK_Example_Wechat with MIT License 4 votes vote down vote up
private LinearLayout getView(int position, OnClickListener ocL, Context context) {
	Bitmap logo;
	String label;
	OnClickListener listener;
	if (beans[position] instanceof Platform) {
		logo = getIcon((Platform) beans[position]);
		label = getName((Platform) beans[position]);
		listener = ocL;
	} else {
		logo = ((CustomerLogo) beans[position]).logo;
		label = ((CustomerLogo) beans[position]).label;
		listener = ((CustomerLogo) beans[position]).listener;
	}

	LinearLayout ll = new LinearLayout(context);
	ll.setOrientation(LinearLayout.VERTICAL);

	ImageView iv = new ImageView(context);
	int dp_5 = cn.sharesdk.framework.utils.R.dipToPx(context, 5);
	iv.setPadding(dp_5, dp_5, dp_5, dp_5);
	iv.setScaleType(ScaleType.CENTER_INSIDE);
	LinearLayout.LayoutParams lpIv = new LinearLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpIv.setMargins(dp_5, dp_5, dp_5, dp_5);
	lpIv.gravity = Gravity.CENTER_HORIZONTAL;
	iv.setLayoutParams(lpIv);
	iv.setImageBitmap(logo);
	ll.addView(iv);

	TextView tv = new TextView(context);
	tv.setTextColor(0xffffffff);
	tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
	tv.setSingleLine();
	tv.setIncludeFontPadding(false);
	LinearLayout.LayoutParams lpTv = new LinearLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpTv.gravity = Gravity.CENTER_HORIZONTAL;
	lpTv.weight = 1;
	lpTv.setMargins(dp_5, 0, dp_5, dp_5);
	tv.setLayoutParams(lpTv);
	tv.setText(label);
	ll.addView(tv);
	ll.setOnClickListener(listener);

	return ll;
}
 
Example 9
Source File: PlatformGridView.java    From AndroidLinkup with GNU General Public License v2.0 4 votes vote down vote up
private LinearLayout getView(int position, OnClickListener ocL, Context context) {
	Bitmap logo;
	String label;
	OnClickListener listener;
	if (beans[position] instanceof Platform) {
		logo = getIcon((Platform) beans[position]);
		label = getName((Platform) beans[position]);
		listener = ocL;
	} else {
		logo = ((CustomerLogo) beans[position]).logo;
		label = ((CustomerLogo) beans[position]).label;
		listener = ((CustomerLogo) beans[position]).listener;
	}

	LinearLayout ll = new LinearLayout(context);
	ll.setOrientation(LinearLayout.VERTICAL);

	ImageView iv = new ImageView(context);
	int dp_5 = cn.sharesdk.framework.utils.R.dipToPx(context, 5);
	iv.setPadding(dp_5, dp_5, dp_5, dp_5);
	iv.setScaleType(ScaleType.CENTER_INSIDE);
	LinearLayout.LayoutParams lpIv = new LinearLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpIv.setMargins(dp_5, dp_5, dp_5, dp_5);
	lpIv.gravity = Gravity.CENTER_HORIZONTAL;
	iv.setLayoutParams(lpIv);
	iv.setImageBitmap(logo);
	ll.addView(iv);

	TextView tv = new TextView(context);
	tv.setTextColor(0xffffffff);
	tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
	tv.setSingleLine();
	tv.setIncludeFontPadding(false);
	LinearLayout.LayoutParams lpTv = new LinearLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpTv.gravity = Gravity.CENTER_HORIZONTAL;
	lpTv.weight = 1;
	lpTv.setMargins(dp_5, 0, dp_5, dp_5);
	tv.setLayoutParams(lpTv);
	tv.setText(label);
	ll.addView(tv);
	ll.setOnClickListener(listener);

	return ll;
}
 
Example 10
Source File: PlatformGridView.java    From ShareSDKShareDifMsgDemo-Android with MIT License 4 votes vote down vote up
private LinearLayout getView(int position, OnClickListener ocL, Context context) {
	Bitmap logo;
	String label;
	OnClickListener listener;
	if (beans[position] instanceof Platform) {
		logo = getIcon((Platform) beans[position]);
		label = getName((Platform) beans[position]);
		listener = ocL;
	} else {
		logo = ((CustomerLogo) beans[position]).logo;
		label = ((CustomerLogo) beans[position]).label;
		listener = ((CustomerLogo) beans[position]).listener;
	}

	LinearLayout ll = new LinearLayout(context);
	ll.setOrientation(LinearLayout.VERTICAL);

	ImageView iv = new ImageView(context);
	int dp_5 = cn.sharesdk.framework.utils.R.dipToPx(context, 5);
	iv.setPadding(dp_5, dp_5, dp_5, dp_5);
	iv.setScaleType(ScaleType.CENTER_INSIDE);
	LinearLayout.LayoutParams lpIv = new LinearLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpIv.setMargins(dp_5, dp_5, dp_5, dp_5);
	lpIv.gravity = Gravity.CENTER_HORIZONTAL;
	iv.setLayoutParams(lpIv);
	iv.setImageBitmap(logo);
	ll.addView(iv);

	TextView tv = new TextView(context);
	tv.setTextColor(0xffffffff);
	tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
	tv.setSingleLine();
	tv.setIncludeFontPadding(false);
	LinearLayout.LayoutParams lpTv = new LinearLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpTv.gravity = Gravity.CENTER_HORIZONTAL;
	lpTv.weight = 1;
	lpTv.setMargins(dp_5, 0, dp_5, dp_5);
	tv.setLayoutParams(lpTv);
	tv.setText(label);
	ll.addView(tv);
	ll.setOnClickListener(listener);

	return ll;
}
 
Example 11
Source File: PlatformGridView.java    From WeCenterMobile-Android with GNU General Public License v2.0 4 votes vote down vote up
private LinearLayout getView(int position, OnClickListener ocL, Context context) {
	Bitmap logo;
	String label;
	OnClickListener listener;
	if (beans[position] instanceof Platform) {
		logo = getIcon((Platform) beans[position]);
		label = getName((Platform) beans[position]);
		listener = ocL;
	} else {
		logo = ((CustomerLogo) beans[position]).logo;
		label = ((CustomerLogo) beans[position]).label;
		listener = ((CustomerLogo) beans[position]).listener;
	}

	LinearLayout ll = new LinearLayout(context);
	ll.setOrientation(LinearLayout.VERTICAL);

	ImageView iv = new ImageView(context);
	int dp_5 = cn.sharesdk.framework.utils.R.dipToPx(context, 5);
	iv.setPadding(dp_5, dp_5, dp_5, dp_5);
	iv.setScaleType(ScaleType.CENTER_INSIDE);
	LinearLayout.LayoutParams lpIv = new LinearLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpIv.setMargins(dp_5, dp_5, dp_5, dp_5);
	lpIv.gravity = Gravity.CENTER_HORIZONTAL;
	iv.setLayoutParams(lpIv);
	iv.setImageBitmap(logo);
	ll.addView(iv);

	TextView tv = new TextView(context);
	tv.setTextColor(0xffffffff);
	tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
	tv.setSingleLine();
	tv.setIncludeFontPadding(false);
	LinearLayout.LayoutParams lpTv = new LinearLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpTv.gravity = Gravity.CENTER_HORIZONTAL;
	lpTv.weight = 1;
	lpTv.setMargins(dp_5, 0, dp_5, dp_5);
	tv.setLayoutParams(lpTv);
	tv.setText(label);
	ll.addView(tv);
	ll.setOnClickListener(listener);

	return ll;
}
 
Example 12
Source File: Style.java    From TabletClock with MIT License 4 votes vote down vote up
private static void applyTimeViewExcludeSize(TextView timeView) {
	timeView.setTypeface(mFont);
	timeView.setPadding(0, 0, 0, 0);
	timeView.setSingleLine(true);
	timeView.setIncludeFontPadding(false);
}
 
Example 13
Source File: Style.java    From TabletClock with MIT License 4 votes vote down vote up
public static void applyTextsView(TextView textView, float height) {
	textView.setTypeface(mFont);
	textView.setTextSize(PxToSp(height));
	textView.setSingleLine(true);
	textView.setIncludeFontPadding(false);
}
 
Example 14
Source File: BubbleContainer.java    From actor-platform with GNU Affero General Public License v3.0 4 votes vote down vote up
private void init() {

        setWillNotDraw(false);

        SELECTOR_PAINT.setColor(getResources().getColor(R.color.selector_selected));
        SELECTOR_PAINT.setStyle(Paint.Style.FILL);

        // DATE

        showDateDiv = false;

        dateDiv = new TextView(getContext());
        dateDiv.setTextSize(12);
        dateDiv.setTypeface(Fonts.regular());
        dateDiv.setIncludeFontPadding(false);
        dateDiv.setBackgroundResource(R.drawable.conv_bubble_date_bg);
        dateDiv.setGravity(Gravity.CENTER);
        dateDiv.setTextColor(ActorSDK.sharedActor().style.getConvDatetextColor());

        if (!showDateDiv) {
            dateDiv.setVisibility(GONE);
        } else {
            dateDiv.setVisibility(VISIBLE);
        }

        addView(dateDiv, new MarginLayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

        // UNREAD

        showUnreadDiv = false;

        unreadDiv = new TextView(getContext());
        unreadDiv.setTextSize(13);
        unreadDiv.setTypeface(Fonts.regular());
        unreadDiv.setIncludeFontPadding(false);
        unreadDiv.setBackgroundColor(ActorSDK.sharedActor().style.getConvDateBgColor());
        unreadDiv.setGravity(Gravity.CENTER);
        unreadDiv.setTextColor(ActorSDK.sharedActor().style.getConvDatetextColor());
        unreadDiv.setPadding(0, Screen.dp(6), 0, Screen.dp(6));
        unreadDiv.setText(R.string.chat_new_messages);

        if (!showUnreadDiv) {
            unreadDiv.setVisibility(GONE);
        } else {
            unreadDiv.setVisibility(VISIBLE);
        }

        addView(unreadDiv, new MarginLayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

        // AVATAR
        avatarView = new AvatarViewWithOnline(getContext());
        avatarView.init(Screen.dp(42), 18);
        addView(avatarView, new MarginLayoutParams(Screen.dp(42), Screen.dp(42)));
    }
 
Example 15
Source File: TextSizeAttr.java    From AutoLayout-Android with Apache License 2.0 4 votes vote down vote up
@Override
protected void execute(TextView textView, int val) {
    textView.setIncludeFontPadding(false);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, val);
}
 
Example 16
Source File: PlatformGridView.java    From BigApp_WordPress_Android with Apache License 2.0 4 votes vote down vote up
private LinearLayout getView(int position, OnClickListener ocL, Context context) {
	Bitmap logo;
	String label;
	OnClickListener listener;
	if (beans[position] instanceof Platform) {
		logo = getIcon((Platform) beans[position]);
		label = getName((Platform) beans[position]);
		listener = ocL;
	} else {
		logo = ((CustomerLogo) beans[position]).enableLogo;
		label = ((CustomerLogo) beans[position]).label;
		listener = ocL;
	}

	LinearLayout ll = new LinearLayout(context);
	ll.setOrientation(LinearLayout.VERTICAL);

	ImageView iv = new ImageView(context);
	int dp_5 = com.mob.tools.utils.R.dipToPx(context, 5);
	iv.setPadding(dp_5, dp_5, dp_5, dp_5);
	iv.setScaleType(ScaleType.CENTER_INSIDE);
	LayoutParams lpIv = new LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpIv.setMargins(dp_5, dp_5, dp_5, dp_5);
	lpIv.gravity = Gravity.CENTER_HORIZONTAL;
	iv.setLayoutParams(lpIv);
	iv.setImageBitmap(logo);
	ll.addView(iv);

	TextView tv = new TextView(context);
	tv.setTextColor(0xff303030);
	tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
	tv.setSingleLine();
	tv.setIncludeFontPadding(false);
	LayoutParams lpTv = new LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpTv.gravity = Gravity.CENTER_HORIZONTAL;
	lpTv.weight = 1;
	lpTv.setMargins(dp_5, 0, dp_5, dp_5);
	tv.setLayoutParams(lpTv);
	tv.setText(label);
	ll.addView(tv);
	ll.setOnClickListener(listener);

	return ll;
}
 
Example 17
Source File: PlatformGridView.java    From BigApp_Discuz_Android with Apache License 2.0 4 votes vote down vote up
private LinearLayout getView(int position, OnClickListener ocL, Context context) {
	Bitmap logo;
	String label;
	OnClickListener listener;
	if (beans[position] instanceof Platform) {
		logo = getIcon((Platform) beans[position]);
		label = getName((Platform) beans[position]);
		listener = ocL;
	} else {
		logo = ((CustomerLogo) beans[position]).enableLogo;
		label = ((CustomerLogo) beans[position]).label;
		listener = ocL;
	}

	LinearLayout ll = new LinearLayout(context);
	ll.setOrientation(LinearLayout.VERTICAL);

	ImageView iv = new ImageView(context);
	int dp_5 = com.mob.tools.utils.R.dipToPx(context, 5);
	iv.setPadding(dp_5, dp_5, dp_5, dp_5);
	iv.setScaleType(ScaleType.CENTER_INSIDE);
	LayoutParams lpIv = new LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpIv.setMargins(dp_5, dp_5, dp_5, dp_5);
	lpIv.gravity = Gravity.CENTER_HORIZONTAL;
	iv.setLayoutParams(lpIv);
	iv.setImageBitmap(logo);
	ll.addView(iv);

	TextView tv = new TextView(context);
	tv.setTextColor(0xff000000);
	tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
	tv.setSingleLine();
	tv.setIncludeFontPadding(false);
	LayoutParams lpTv = new LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpTv.gravity = Gravity.CENTER_HORIZONTAL;
	lpTv.weight = 1;
	lpTv.setMargins(dp_5, 0, dp_5, dp_5);
	tv.setLayoutParams(lpTv);
	tv.setText(label);
	ll.addView(tv);
	ll.setOnClickListener(listener);

	return ll;
}
 
Example 18
Source File: PlatformGridView.java    From Huochexing12306 with Apache License 2.0 4 votes vote down vote up
private LinearLayout getView(int position, OnClickListener ocL, Context context) {
			Bitmap logo;
			String label;
			OnClickListener listener;
			if (beans[position] instanceof Platform) {
				logo = getIcon((Platform) beans[position]);
				label = getName((Platform) beans[position]);
				listener = ocL;
			} else {
				logo = ((CustomerLogo) beans[position]).logo;
				label = ((CustomerLogo) beans[position]).label;
				listener = ((CustomerLogo) beans[position]).listener;
			}

			LinearLayout ll = new LinearLayout(context);
			ll.setOrientation(LinearLayout.VERTICAL);

			ImageView iv = new ImageView(context);
			int dp_5 = cn.sharesdk.framework.utils.R.dipToPx(context, 5);
			iv.setPadding(dp_5, dp_5, dp_5, dp_5);
			iv.setScaleType(ScaleType.CENTER_INSIDE);
			LinearLayout.LayoutParams lpIv = new LinearLayout.LayoutParams(
					LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
			lpIv.setMargins(dp_5, dp_5, dp_5, dp_5);
			lpIv.gravity = Gravity.CENTER_HORIZONTAL;
			iv.setLayoutParams(lpIv);
			iv.setImageBitmap(logo);
			ll.addView(iv);

			TextView tv = new TextView(context);
//			tv.setTextColor(0x2A1E21);
			tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
			tv.setSingleLine();
			tv.setIncludeFontPadding(false);
			LinearLayout.LayoutParams lpTv = new LinearLayout.LayoutParams(
					LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
			lpTv.gravity = Gravity.CENTER_HORIZONTAL;
			lpTv.weight = 1;
			lpTv.setMargins(dp_5, 0, dp_5, dp_5);
			tv.setLayoutParams(lpTv);
			tv.setText(Html.fromHtml("<font color='black'>"+label+"</font>"));
			ll.addView(tv);
			ll.setOnClickListener(listener);

			return ll;
		}