private void addTextView() {
    removeAllViews();
    if (mIndexListSize < 1) {
      return;
    }

    TextView tmpTV;
    for (double i = 1; i <= mIndexListSize; i++) {
      String tmpAlphabet = mAlphabetList.get((int) i - 1).firstAlphabet;

      tmpTV = new TextView(getContext());
      tmpTV.setText(tmpAlphabet);
      tmpTV.setGravity(Gravity.CENTER);
      tmpTV.setTextSize(TypedValue.COMPLEX_UNIT_PX, mAlphabetTextSize);
      tmpTV.setTextColor(Color.BLACK);
      LinearLayout.LayoutParams params =
          new LinearLayout.LayoutParams(
              ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1);
      params.leftMargin = mAlphabetLeftMargin;
      tmpTV.setLayoutParams(params);
      tmpTV.setIncludeFontPadding(false);

      addView(tmpTV);
    }
  }
  private void supportTextSize(View view, AutoLayoutInfo info) {
    if (!(view instanceof TextView)) return;
    if (info.textSize == 0) return;

    boolean textSizeBaseWidth = info.textSizeBaseWidth;
    float textSize;
    if (textSizeBaseWidth) {
      textSize = info.textSize * 1.0f / getDesignWidth() * getAvailableWidth();
    } else {
      textSize = info.textSize * 1.0f / getDesignHeight() * getAvailaleHegiht();
    }
    // textSize = textSize / 1.34f;

    ((TextView) view).setIncludeFontPadding(false);
    ((TextView) view).setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
  }
Пример #3
0
    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;
    }
Пример #4
0
  public DialogHolder(
      Context context, FrameLayout fl, final OnItemClickedListener<Dialog> onClickListener) {
    super(fl);

    this.context = context;

    final int paddingH = Screen.dp(11);
    final int paddingV = Screen.dp(9);

    pendingColor = context.getResources().getColor(R.color.chats_state_pending);
    sentColor = context.getResources().getColor(R.color.chats_state_sent);
    receivedColor = context.getResources().getColor(R.color.chats_state_delivered);
    readColor = context.getResources().getColor(R.color.chats_state_read);
    errorColor = context.getResources().getColor(R.color.chats_state_error);

    fl.setLayoutParams(
        new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(73)));
    fl.setBackgroundResource(R.drawable.selector_fill);

    avatar = new AvatarView(context);
    avatar.init(Screen.dp(52), 24);
    {
      FrameLayout.LayoutParams avatarLayoutParams =
          new FrameLayout.LayoutParams(Screen.dp(52), Screen.dp(52));
      avatarLayoutParams.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT;
      avatarLayoutParams.leftMargin = paddingH;
      avatar.setLayoutParams(avatarLayoutParams);
    }
    fl.addView(avatar);

    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setGravity(Gravity.TOP);
    {
      FrameLayout.LayoutParams layoutParams =
          new FrameLayout.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
      layoutParams.rightMargin = paddingH;
      layoutParams.leftMargin = Screen.dp(79);
      layoutParams.topMargin = paddingV;
      layoutParams.bottomMargin = paddingV;
      linearLayout.setLayoutParams(layoutParams);
    }

    LinearLayout firstRow = new LinearLayout(context);
    firstRow.setOrientation(LinearLayout.HORIZONTAL);
    {
      LinearLayout.LayoutParams params =
          new LinearLayout.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      firstRow.setLayoutParams(params);
    }

    title = new TextView(context);
    title.setTextColor(context.getResources().getColor(R.color.chats_title));
    title.setTypeface(Fonts.medium());
    title.setTextSize(17);
    title.setPadding(0, Screen.dp(1), 0, 0);
    title.setSingleLine();
    title.setCompoundDrawablePadding(Screen.dp(4));
    title.setEllipsize(TextUtils.TruncateAt.END);
    {
      LinearLayout.LayoutParams params =
          new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT);
      params.weight = 1;
      title.setLayoutParams(params);
    }
    firstRow.addView(title);

    time = new TextView(context);
    time.setTextColor(context.getResources().getColor(R.color.chats_time));
    time.setTypeface(Fonts.regular());
    time.setTextSize(13);
    time.setPadding(Screen.dp(6), 0, 0, 0);
    time.setSingleLine();
    firstRow.addView(time);

    linearLayout.addView(firstRow);

    text = new TextView(context);
    text.setTypeface(Fonts.regular());
    text.setTextColor(context.getResources().getColor(R.color.chats_text));
    text.setTextSize(15);
    text.setPadding(0, Screen.dp(5), Screen.dp(28), 0);
    text.setSingleLine();
    text.setEllipsize(TextUtils.TruncateAt.END);
    linearLayout.addView(text);

    fl.addView(linearLayout);

    separator = new View(context);
    separator.setBackgroundColor(context.getResources().getColor(R.color.chats_divider));
    FrameLayout.LayoutParams divLayoutParams =
        new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            context.getResources().getDimensionPixelSize(R.dimen.div_size));
    divLayoutParams.leftMargin = Screen.dp(76);
    divLayoutParams.gravity = Gravity.BOTTOM;
    fl.addView(separator, divLayoutParams);

    state = new TintImageView(context);
    {
      FrameLayout.LayoutParams params =
          new FrameLayout.LayoutParams(
              Screen.dp(28), Screen.dp(12), Gravity.BOTTOM | Gravity.RIGHT);
      params.bottomMargin = Screen.dp(16);
      params.rightMargin = Screen.dp(9);
      state.setLayoutParams(params);
      fl.addView(state);
    }

    counter = new TextView(context);
    counter.setTextColor(context.getResources().getColor(R.color.chats_counter));
    counter.setBackgroundColor(context.getResources().getColor(R.color.chats_counter_bg));
    counter.setPadding(Screen.dp(4), 0, Screen.dp(4), 0);
    counter.setTextSize(10);
    counter.setTypeface(Fonts.regular());
    counter.setGravity(Gravity.CENTER);
    counter.setIncludeFontPadding(false);
    counter.setMinWidth(Screen.dp(14));
    {
      FrameLayout.LayoutParams params =
          new FrameLayout.LayoutParams(
              ViewGroup.LayoutParams.WRAP_CONTENT, Screen.dp(14), Gravity.BOTTOM | Gravity.RIGHT);
      params.bottomMargin = Screen.dp(12);
      params.rightMargin = Screen.dp(10);
      counter.setLayoutParams(params);
      fl.addView(counter);
    }

    fl.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (bindedItem != null) {
              onClickListener.onClicked(bindedItem);
            }
          }
        });
    fl.setOnLongClickListener(
        new View.OnLongClickListener() {
          @Override
          public boolean onLongClick(View v) {
            if (bindedItem != null) {
              return onClickListener.onLongClicked(bindedItem);
            }
            return false;
          }
        });
  }