当前位置: 首页>>代码示例>>Java>>正文


Java RemoteViews.setTextViewTextSize方法代码示例

本文整理汇总了Java中android.widget.RemoteViews.setTextViewTextSize方法的典型用法代码示例。如果您正苦于以下问题:Java RemoteViews.setTextViewTextSize方法的具体用法?Java RemoteViews.setTextViewTextSize怎么用?Java RemoteViews.setTextViewTextSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.RemoteViews的用法示例。


在下文中一共展示了RemoteViews.setTextViewTextSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testNotificationAdapter

import android.widget.RemoteViews; //导入方法依赖的package包/类
@Test
public void testNotificationAdapter() {
    final String NOTIFICATION_TEXT = "adapter-text";
    final String NOTIFICATION_TITLE = "adapter-title";
    final long TIMEOUT = 5000;

    Context appContext = InstrumentationRegistry.getTargetContext();

    RemoteViews contentView = new RemoteViews("cn.dreamtobe.toolset.test", R.layout.custom_layout);
    contentView.setTextViewText(R.id.title, NOTIFICATION_TITLE);
    contentView.setTextViewText(R.id.text, NOTIFICATION_TEXT);

    // Fix the Notification-Style problem ---------------
    // Set the default title style color to title view.
    contentView.setTextColor(R.id.title, NotificationAdapter.getTitleColor(appContext));
    // Set the default title style size to title view
    contentView.setTextViewTextSize(R.id.title, COMPLEX_UNIT_PX, NotificationAdapter.getTitleSize(appContext));
    // Set the default text style color to text view
    contentView.setTextColor(R.id.text, NotificationAdapter.getTextColor(appContext));
    // Set the default text style size to text view
    contentView.setTextViewTextSize(R.id.text, COMPLEX_UNIT_PX, NotificationAdapter.getTextSize(appContext));
    // End fix the Notification-Style problem ---------------

    Notification notification = new Notification();
    notification.icon = R.drawable.ic_launcher;
    notification.contentView = contentView;

    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    notification.defaults |= Notification.DEFAULT_SOUND;
    notification.defaults |= Notification.DEFAULT_VIBRATE;

    NotificationManager notifyMgr =
            (NotificationManager) appContext.getSystemService(NOTIFICATION_SERVICE);
    notifyMgr.notify(1, notification);

    UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
    device.openNotification();
    device.wait(Until.hasObject(By.text(NOTIFICATION_TITLE)), TIMEOUT);
}
 
开发者ID:Jacksgong,项目名称:notification-adapter,代码行数:40,代码来源:NotificationAdapterTest.java

示例2: settingUpViews

import android.widget.RemoteViews; //导入方法依赖的package包/类
private static void settingUpViews(Context context, int appWidgetId) {
    CharSequence widgetText = context.getString(R.string.appwidget_text_loading);
    int backgroundColor = AppWidgetConfigureActivity.loadBackgroundColorPref(context, appWidgetId);
    int buttonColor = AppWidgetConfigureActivity.loadButtonColorPref(context, appWidgetId);
    int textColor = AppWidgetConfigureActivity.loadTextColorPref(context, appWidgetId);

    // Construct the RemoteViews object
    views = new RemoteViews(context.getPackageName(), R.layout.app_widget);
    views.setTextViewText(R.id.appwidgetText, widgetText);
    views.setTextViewTextSize(R.id.appwidgetText, TypedValue.COMPLEX_UNIT_SP, AppSettings.textSizeWidget(context));
    views.setInt(R.id.relativeLayout, "setBackgroundColor", backgroundColor);
    views.setTextColor(R.id.updateButton, buttonColor);
    views.setTextColor(R.id.appwidgetText, textColor);
}
 
开发者ID:personaljesusua,项目名称:DepressingThoughts,代码行数:15,代码来源:AppWidget.java

示例3: applyStandardTemplate

import android.widget.RemoteViews; //导入方法依赖的package包/类
private static RemoteViews applyStandardTemplate(Context context, CharSequence contentTitle, CharSequence contentText, CharSequence contentInfo, int number, Bitmap largeIcon, CharSequence subText, boolean useChronometer, long when, int resId, boolean fitIn1U) {
    RemoteViews contentView = new RemoteViews(context.getPackageName(), resId);
    boolean showLine3 = false;
    boolean showLine2 = false;
    if (largeIcon == null || VERSION.SDK_INT < 16) {
        contentView.setViewVisibility(R.id.icon, 8);
    } else {
        contentView.setViewVisibility(R.id.icon, 0);
        contentView.setImageViewBitmap(R.id.icon, largeIcon);
    }
    if (contentTitle != null) {
        contentView.setTextViewText(R.id.title, contentTitle);
    }
    if (contentText != null) {
        contentView.setTextViewText(R.id.text, contentText);
        showLine3 = true;
    }
    if (contentInfo != null) {
        contentView.setTextViewText(R.id.info, contentInfo);
        contentView.setViewVisibility(R.id.info, 0);
        showLine3 = true;
    } else if (number > 0) {
        if (number > context.getResources().getInteger(R.integer.status_bar_notification_info_maxnum)) {
            contentView.setTextViewText(R.id.info, context.getResources().getString(R.string.status_bar_notification_info_overflow));
        } else {
            contentView.setTextViewText(R.id.info, NumberFormat.getIntegerInstance().format((long) number));
        }
        contentView.setViewVisibility(R.id.info, 0);
        showLine3 = true;
    } else {
        contentView.setViewVisibility(R.id.info, 8);
    }
    if (subText != null && VERSION.SDK_INT >= 16) {
        contentView.setTextViewText(R.id.text, subText);
        if (contentText != null) {
            contentView.setTextViewText(R.id.text2, contentText);
            contentView.setViewVisibility(R.id.text2, 0);
            showLine2 = true;
        } else {
            contentView.setViewVisibility(R.id.text2, 8);
        }
    }
    if (showLine2 && VERSION.SDK_INT >= 16) {
        if (fitIn1U) {
            contentView.setTextViewTextSize(R.id.text, 0, (float) context.getResources().getDimensionPixelSize(R.dimen.notification_subtext_size));
        }
        contentView.setViewPadding(R.id.line1, 0, 0, 0, 0);
    }
    if (when != 0) {
        if (useChronometer) {
            contentView.setViewVisibility(R.id.chronometer, 0);
            contentView.setLong(R.id.chronometer, "setBase", (SystemClock.elapsedRealtime() - System.currentTimeMillis()) + when);
            contentView.setBoolean(R.id.chronometer, "setStarted", true);
        } else {
            contentView.setViewVisibility(R.id.time, 0);
            contentView.setLong(R.id.time, "setTime", when);
        }
    }
    contentView.setViewVisibility(R.id.line3, showLine3 ? 0 : 8);
    return contentView;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:62,代码来源:NotificationCompatImplBase.java

示例4: getNotificationBuilder

import android.widget.RemoteViews; //导入方法依赖的package包/类
/**
 * Gets Notification.Builder with 2 lines at BigPictureStyle notification text.
 *
 * @param context The application context.
 * @param message Push notification Bundle.
 * @param contentIntent PendingIntent.
 * @param title String with title for push notification.
 * @param messageText String with text for push notification.
 * @param bigPicture Bitmap for BigPictureStyle notification.
 * @param defaultNotificationIconResourceId int Resource id for default push notification icon.
 * @return Notification.Builder or null.
 */
static Notification.Builder getNotificationBuilder(Context context, Bundle message,
    PendingIntent contentIntent, String title, final String messageText, Bitmap bigPicture,
    int defaultNotificationIconResourceId) {
  if (Build.VERSION.SDK_INT < 16) {
    return null;
  }
  Notification.Builder notificationBuilder =
      getNotificationBuilder(context, message);
  if (defaultNotificationIconResourceId == 0) {
    notificationBuilder.setSmallIcon(context.getApplicationInfo().icon);
  } else {
    notificationBuilder.setSmallIcon(defaultNotificationIconResourceId);
  }
  notificationBuilder.setContentTitle(title)
      .setContentText(messageText);
  Notification.BigPictureStyle bigPictureStyle = new Notification.BigPictureStyle() {
    @Override
    protected RemoteViews getStandardView(int layoutId) {
      RemoteViews remoteViews = super.getStandardView(layoutId);
      // Modifications of stanxdard push RemoteView.
      try {
        int id = Resources.getSystem().getIdentifier("text", "id", "android");
        remoteViews.setBoolean(id, "setSingleLine", false);
        remoteViews.setInt(id, "setLines", 2);
        if (Build.VERSION.SDK_INT < 23) {
          // Make text smaller.
          remoteViews.setViewPadding(id, 0, BIGPICTURE_TEXT_TOP_PADDING, 0, 0);
          remoteViews.setTextViewTextSize(id, TypedValue.COMPLEX_UNIT_SP, BIGPICTURE_TEXT_SIZE);
        }
      } catch (Throwable throwable) {
        Log.e("Cannot modify push notification layout.");
      }
      return remoteViews;
    }
  };

  bigPictureStyle.bigPicture(bigPicture)
      .setBigContentTitle(title)
      .setSummaryText(message.getString(Constants.Keys.PUSH_MESSAGE_TEXT));
  notificationBuilder.setStyle(bigPictureStyle);

  if (Build.VERSION.SDK_INT >= 24) {
    // By default we cannot reach getStandardView method on API>=24. I we call
    // createBigContentView, Android will call getStandardView method and we can get
    // modified RemoteView.
    try {
      RemoteViews remoteView = notificationBuilder.createBigContentView();
      if (remoteView != null) {
        // We need to set received RemoteView as a custom big content view.
        notificationBuilder.setCustomBigContentView(remoteView);
      }
    } catch (Throwable t) {
      Log.e("Cannot modify push notification layout.", t);
    }
  }

  notificationBuilder.setAutoCancel(true);
  notificationBuilder.setContentIntent(contentIntent);
  return notificationBuilder;
}
 
开发者ID:Leanplum,项目名称:Leanplum-Android-SDK,代码行数:73,代码来源:LeanplumNotificationHelper.java


注:本文中的android.widget.RemoteViews.setTextViewTextSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。