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

The following examples show how to use android.widget.TextView#setMinHeight() . These examples are extracted from open source projects. 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 Project: httplite   File: LeftMenuAdapter.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public MenuViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    TextView textView = new TextView(parent.getContext());
    textView.setTextColor(parent.getResources().getColor(R.color.black));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
    textView.setGravity(Gravity.CENTER);
    textView.setMinWidth(parent.getWidth());
    textView.setMinHeight(parent.getHeight()/10);
    textView.setPadding(0,10,0,10);
    final MenuViewHolder holder = new MenuViewHolder(textView);
    textView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mItemClickListener.onItemClick(mList.get(holder.postion));
        }
    });
    return holder;
}
 
Example 2
public HeaderCell(Context context, String textColorKey, int padding, int topMargin, boolean text2) {
    super(context);

    textView = new TextView(getContext());
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
    textView.setMinHeight(AndroidUtilities.dp(height - topMargin));
    textView.setTextColor(Theme.getColor(textColorKey));
    textView.setTag(textColorKey);
    addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, padding, topMargin, padding, 0));

    if (text2) {
        textView2 = new SimpleTextView(getContext());
        textView2.setTextSize(13);
        textView2.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP);
        addView(textView2, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP, padding, 21, padding, 0));
    }
}
 
Example 3
public HeaderCell(Context context, String textColorKey, int padding, int topMargin, boolean text2) {
    super(context);

    textView = new TextView(getContext());
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
    textView.setMinHeight(AndroidUtilities.dp(height - topMargin));
    textView.setTextColor(Theme.getColor(textColorKey));
    textView.setTag(textColorKey);
    addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, padding, topMargin, padding, 0));

    if (text2) {
        textView2 = new SimpleTextView(getContext());
        textView2.setTextSize(13);
        textView2.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP);
        addView(textView2, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP, padding, 21, padding, 0));
    }
}
 
Example 4
/**
 * Sets the minimum height of a text view.
 *
 * @param textview text view instance
 * @param minHeight minimum height of the text view in pixels
 */
public static void setMinHeight(TextView textview, int minHeight) {
  // According to https://developer.android.com/reference/android/widget/TextView.html#setMinHeight(int), the minimum
  // height of TextView is the maximum of setMinHeight and setMinimumHeight. Talk about NIH syndrome!
  textview.setMinHeight(minHeight);
  textview.setMinimumHeight(minHeight);
}
 
Example 5
public View getView(int position, View convertView, ViewGroup parent) {

      LinearLayout ll = new LinearLayout(context);
      ll.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
          LayoutParams.FILL_PARENT));
      ll.setMinimumHeight(50);
      ll.setOrientation(LinearLayout.HORIZONTAL);
      ll.setGravity(Gravity.CENTER_VERTICAL);

      ImageView iv = new ImageView(context);
      iv.setImageResource(applications.get(position).getIconResId());
      iv.setAdjustViewBounds(true);
      iv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.WRAP_CONTENT,
          LayoutParams.WRAP_CONTENT));
      if (listView.getCheckedItemPosition() == position) {
        iv.setBackgroundResource(R.drawable.icon_hilight);
      }

      TextView tv = new TextView(context);
      tv.setText(applications.get(position).getDescriptionShort());
      tv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
          LayoutParams.FILL_PARENT));
      tv.setGravity(Gravity.CENTER_VERTICAL);
      tv.setPadding(10, 0, 0, 0);
      tv.setTextSize(14.0f);
      tv.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
      tv.setTextColor(context.getResources().getColor(R.color.list_element_text));
      tv.setMinHeight(46);

      ll.addView(iv);
      ll.addView(tv);

      return ll;
    }
 
Example 6
Source Project: LibreTasks   File: ActivityDlgActions.java    License: Apache License 2.0 5 votes vote down vote up
public View getView(int position, View convertView, ViewGroup parent) {

      LinearLayout ll = new LinearLayout(context);
      ll.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
          LayoutParams.FILL_PARENT));
      ll.setMinimumHeight(50);
      ll.setOrientation(LinearLayout.HORIZONTAL);
      ll.setGravity(Gravity.CENTER_VERTICAL);

      ImageView iv = new ImageView(context);
      iv.setImageResource(actions.get(position).getIconResId());
      iv.setAdjustViewBounds(true);
      iv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.WRAP_CONTENT,
          LayoutParams.WRAP_CONTENT));
      if (listView.getCheckedItemPosition() == position) {
        iv.setBackgroundResource(R.drawable.icon_hilight);
      }

      TextView tv = new TextView(context);
      tv.setText(actions.get(position).getDescriptionShort());
      tv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
          LayoutParams.FILL_PARENT));
      tv.setGravity(Gravity.CENTER_VERTICAL);
      tv.setPadding(10, 0, 0, 0);
      tv.setTextSize(14.0f);
      tv.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
      tv.setTextColor(context.getResources().getColor(R.color.list_element_text));
      tv.setMinHeight(46);

      ll.addView(iv);
      ll.addView(tv);

      return ll;
    }
 
Example 7
public View getView(int position, View convertView, ViewGroup parent) {
  LinearLayout ll = new LinearLayout(context);
  ll.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
      LayoutParams.FILL_PARENT));
  ll.setMinimumHeight(50);
  ll.setOrientation(LinearLayout.HORIZONTAL);
  ll.setGravity(Gravity.CENTER_VERTICAL);

  ImageView iv = new ImageView(context);
  iv.setImageResource(attributes.get(position).getIconResId());
  iv.setAdjustViewBounds(true);
  iv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.WRAP_CONTENT,
      LayoutParams.WRAP_CONTENT));
  if (listView.getCheckedItemPosition() == position) {
    iv.setBackgroundResource(R.drawable.icon_hilight);
  }

  TextView tv = new TextView(context);
  tv.setText(attributes.get(position).getDescriptionShort());
  tv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
      LayoutParams.FILL_PARENT));
  tv.setGravity(Gravity.CENTER_VERTICAL);
  tv.setPadding(10, 0, 0, 0);
  tv.setTextSize(14.0f);
  tv.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
  tv.setTextColor(0xFFFFFFFF);
  tv.setMinHeight(46);

  ll.addView(iv);
  ll.addView(tv);

  return ll;
}
 
Example 8
Source Project: LibreTasks   File: ActivityLogTabs.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * This function will be called once for every element in the listView control, when it needs to
 * draw itself. It should return a constructed view representing the data in the position
 * specified. Each element in the listView is a Log item, so we display the Log's icon and
 * title.
 * 
 * TODO: Use convertView when possible instead of always creating new views.
 */
public View getView(int position, View convertView, ViewGroup parent) {
  LinearLayout ll = new LinearLayout(context);
  ll.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
      LayoutParams.FILL_PARENT));
  ll.setMinimumHeight(50);
  ll.setOrientation(LinearLayout.HORIZONTAL);
  ll.setGravity(Gravity.CENTER_VERTICAL);

  // Icon of the log.
  ImageView iv = new ImageView(context);
  iv.setImageResource(logs.get(position).getIconResId());
  iv.setAdjustViewBounds(true);
  iv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.WRAP_CONTENT,
      LayoutParams.WRAP_CONTENT));
  if (listView.getCheckedItemPosition() == position) {
    iv.setBackgroundResource(R.drawable.icon_hilight);
  }

  // Title of the log.
  TextView tv = new TextView(context);
  tv.setText(logs.get(position).getText());
  tv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
      LayoutParams.FILL_PARENT));
  tv.setGravity(Gravity.CENTER_VERTICAL);
  tv.setPadding(10, 0, 0, 0);
  tv.setTextSize(14.0f);
  tv.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
  tv.setTextColor(context.getResources().getColor(R.color.list_element_text));
  tv.setMinHeight(46);

  ll.addView(iv);
  ll.addView(tv);
  return ll;
}
 
Example 9
public View getView(int position, View convertView, ViewGroup parent) {

      LinearLayout ll = new LinearLayout(context);
      ll.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
          LayoutParams.FILL_PARENT));
      ll.setMinimumHeight(50);
      ll.setOrientation(LinearLayout.HORIZONTAL);
      ll.setGravity(Gravity.CENTER_VERTICAL);

      ImageView iv = new ImageView(context);
      iv.setImageResource(attributes.get(position).getIconResId());
      iv.setAdjustViewBounds(true);
      iv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.WRAP_CONTENT,
          LayoutParams.WRAP_CONTENT));
      if (listView.getCheckedItemPosition() == position) {
        iv.setBackgroundResource(R.drawable.icon_hilight);
      }

      TextView tv = new TextView(context);
      tv.setText(attributes.get(position).getDescriptionShort());
      tv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
          LayoutParams.FILL_PARENT));
      tv.setGravity(Gravity.CENTER_VERTICAL);
      tv.setPadding(10, 0, 0, 0);
      tv.setTextSize(14.0f);
      tv.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
      tv.setTextColor(context.getResources().getColor(R.color.list_element_text));
      tv.setMinHeight(46);

      ll.addView(iv);
      ll.addView(tv);

      return ll;
    }
 
Example 10
Source Project: LibreTasks   File: ActivityDlgFilters.java    License: Apache License 2.0 5 votes vote down vote up
public View getView(int position, View convertView, ViewGroup parent) {

      LinearLayout ll = new LinearLayout(context);
      ll.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
          LayoutParams.FILL_PARENT));
      ll.setMinimumHeight(50);
      ll.setOrientation(LinearLayout.HORIZONTAL);
      ll.setGravity(Gravity.CENTER_VERTICAL);

      // the icon of the filter
      ImageView iv = new ImageView(context);
      iv.setImageResource(filters.get(position).getIconResId());
      iv.setAdjustViewBounds(true);
      iv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.WRAP_CONTENT,
          LayoutParams.WRAP_CONTENT));
      if (listView.getCheckedItemPosition() == position) {
        iv.setBackgroundResource(R.drawable.icon_hilight);
      }

      // the description of the filter
      TextView tv = new TextView(context);
      tv.setText(filters.get(position).getDescriptionShort());
      tv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
          LayoutParams.FILL_PARENT));
      tv.setGravity(Gravity.CENTER_VERTICAL);
      tv.setPadding(10, 0, 0, 0);
      tv.setTextSize(14.0f);
      tv.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
      tv.setTextColor(context.getResources().getColor(R.color.list_element_text));
      tv.setMinHeight(46);

      ll.addView(iv);
      ll.addView(tv);

      return ll;
    }
 
Example 11
@Override
public View getView(int position, View convertView, ViewGroup parent) {
	IconContextMenuItem item = (IconContextMenuItem) getItem(position);
	Resources res = parentActivity.getResources();
	
	if (convertView == null) {
       	TextView temp = new TextView(context);
       	AbsListView.LayoutParams param = new AbsListView.LayoutParams(AbsListView.LayoutParams.FILL_PARENT, 
       																  AbsListView.LayoutParams.WRAP_CONTENT);
       	temp.setLayoutParams(param);
       	temp.setPadding((int)toPixel(res, 20), 2, (int)toPixel(res, 20), 2);
       	temp.setGravity(android.view.Gravity.CENTER_VERTICAL);
       	Theme th = context.getTheme();
		TypedValue tv = new TypedValue();
		
		if (th.resolveAttribute(android.R.attr.textAppearanceLargeInverse, tv, true)) {
			temp.setTextAppearance(context, tv.resourceId);
		}
       	
       	temp.setMinHeight(LIST_PREFERED_HEIGHT);
       	
       	temp.setCompoundDrawablePadding((int)toPixel(res, 14));
       	convertView = temp;
	}
	
	TextView textView = (TextView) convertView;
	textView.setTag(item);
	textView.setText(item.text);
	textView.setTextColor(Color.WHITE);
	textView.setTypeface(typeface);
	
	Bitmap bitmap = ((BitmapDrawable) item.image).getBitmap();
	Drawable d = new BitmapDrawable(parent.getResources(), Bitmap.createScaledBitmap(bitmap, LIST_PREFERED_HEIGHT, LIST_PREFERED_HEIGHT, true));
	textView.setCompoundDrawablesWithIntrinsicBounds(d, null, null, null);
      	
       return textView;
}
 
Example 12
@SuppressWarnings("deprecation")
@Override public View getView(int position, View convertView, ViewGroup parent) {
          TextView view = (TextView) super.getView(position, convertView, parent);
          view.setTextColor(Color.DKGRAY);
          view.setTag("" + position);
          Item item = getItem(position);
          if (item.type == Item.SECTION) {
              view.setBackgroundColor(parent.getResources().getColor(COLORS[item.sectionPosition % COLORS.length]));
	} else {
		WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
		view.setMinHeight((int) ((Math.abs(new Random().nextGaussian()) * wm.getDefaultDisplay().getHeight())*0.333));
	}
          return view;
      }
 
Example 13
Source Project: zhangshangwuda   File: LessonsFragment.java    License: Apache License 2.0 5 votes vote down vote up
public void setNoClass(LinearLayout ll, int classes, int color) {
	TextView blank = new TextView(getActivity());
	if (color == 0) {
		blank.setMinHeight(classes * minClassHeightPX);
		blank.setMinWidth(minClassWidthPX);
	}
	blank.setBackgroundColor(Color.parseColor(colors[color]));
	ll.addView(blank);
}
 
Example 14
Source Project: imsdk-android   File: RbtSugesstionListView.java    License: MIT License 4 votes vote down vote up
private void addSuggesstion(RbtSuggestionListJson.Item item) {
        // 添加一个横线视图
        addSplitView(subll);
        // 添加问题视图

        final RbtSuggestionListJson.ItemEvent event = item.event;
        final String content = item.text;

        TextView itemView = new TextView(getContext());
        itemView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
        itemView.setTextColor(getContext().getResources().getColorStateList(R.color.atom_ui_light_green2c));
        itemView.setText(content);
        itemView.setGravity(Gravity.CENTER_VERTICAL);
        itemView.setBackgroundResource(R.color.atom_ui_white);

        itemView.setPadding(lineSpace, lineSpace,
                lineSpace, lineSpace);
        itemView.setMinHeight(minHeight);

        OnClickListener onClickListener = new OnClickListener() {
            @Override
            public void onClick(View v) {

                do {
                    if (null == event)
                        break;

                    if (!TextUtils.isEmpty(event.msgText))
                        if (getContext() instanceof IChatView) {
                            ((IChatView) getContext()).sendRobotMsg(event.msgText);
                        }
//                        EventBus.getDefault().post(new QchatConsultEvent.showMsg(event.msgText));

                    if (TextUtils.isEmpty(event.url))
                        break;

                    if ("interface".equalsIgnoreCase(event.type)) {
                        String nameAndValues = Protocol.makeQVTHeader();
                        Map<String, String> cookie = new HashMap<>();
                        cookie.put("Cookie", "cookie=" + nameAndValues);
                        Logger.i("点击问题列表 url:" + event.url);

                        HttpUrlConnectionHandler.executeGet(event.url, cookie, new HttpRequestCallback() {
                            @Override
                            public void onComplete(InputStream response) {

                            }

                            @Override
                            public void onFailure(Exception e) {

                            }
                        });
                        break;
                    }

//                    if ("forward".equalsIgnoreCase(event.type)) {
//                        String schema = ProtocolUtils.makesureAdrSchema(event.url);
//                        SchemeDispatcher.sendScheme(getContext(), schema);
//                        break;
//                    }

                } while (false);
            }
        };
        itemView.setOnClickListener(onClickListener);

        subll.addView(itemView);
    }
 
Example 15
Source Project: SuperDialog   File: SuperDialog.java    License: Apache License 2.0 4 votes vote down vote up
/**
     * 按钮布局
     */
    private void initButtonLayout(ViewGroup viewRoot) {
        LinearLayout buttonRoot = new LinearLayout(context);
        buttonRoot.setOrientation(LinearLayout.HORIZONTAL);
        buttonRoot.setGravity(Gravity.CENTER);
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        lp.setMargins(0, dp2px(5), 0, 0);
        buttonRoot.setLayoutParams(lp);
        for (int i = 0; i < buttonTexts.length; i++) {
            TextView textView = new TextView(context);
            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER);
            layoutParams.weight = 1;
//                layoutParams.setMargins(10, 10, 10, 10);
            textView.setPadding(0, 20, 0, 20);
            textView.setLayoutParams(layoutParams);
            textView.setBackgroundColor(Color.RED);
            textView.setMinHeight(50);
            textView.setTextColor(buttonTextColor);
            textView.setTextSize(buttonTextSize);
            if (buttonTexts.length == 1) {
                textView.setBackgroundDrawable(getButtonBackground(true, true, true));
            } else {
                if (i == 0) {
                    textView.setBackgroundDrawable(getButtonBackground(true, false, true));
                } else if (i == buttonTexts.length - 1) {
                    textView.setBackgroundDrawable(getButtonBackground(false, true, true));
                } else {
                    textView.setBackgroundDrawable(getButtonBackground(false, false, true));
                }
            }
            textView.setGravity(Gravity.CENTER);
            textView.setText(buttonTexts[i]);
            final int finalI = i;
            final int finalI1 = i;
            textView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dismiss();
                    if (listener != null && !isShowInput) {
                        listener.click(true, finalI);
                    }
                    if (inputListener != null && isShowInput) {
                        inputListener.onComplete(finalI1, inputView.getText().toString());
                    }
                }
            });
            buttonRoot.addView(textView);
        }
        viewRoot.addView(buttonRoot);
    }
 
Example 16
/**
 * This function will be called once for every element in the listView control, when it needs to
 * draw itself. It should return a constructed view representing the data in the position
 * specified. Each element in the listView is an Event item, so we display the Event's icon and
 * title.
 * 
 * TODO: Use convertView when possible instead of always creating new views.
 */
public View getView(int position, View convertView, ViewGroup parent) {
  LinearLayout ll = new LinearLayout(context);
  ll.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
      LayoutParams.FILL_PARENT));
  ll.setMinimumHeight(50);
  ll.setOrientation(LinearLayout.HORIZONTAL);
  ll.setGravity(Gravity.CENTER_VERTICAL);

  // Icon of the event.
  ImageView iv = new ImageView(context);
  iv.setImageResource(events.get(position).getIconResId());
  iv.setAdjustViewBounds(true);
  iv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.WRAP_CONTENT,
      LayoutParams.WRAP_CONTENT));
  if (listView.getCheckedItemPosition() == position) {
    iv.setBackgroundResource(R.drawable.icon_hilight);
  }

  // Title of the event.
  TextView tv = new TextView(context);
  String text = events.get(position).getDescriptionShort();

  int numOfRules = UIDbHelperStore.instance().db().getRuleCount(
      events.get(position).getDatabaseId());
  if (numOfRules == 1) {
    text += getString(R.string.one_rule);
  } else if (numOfRules > 1) {
    text += getString(R.string.n_rules, numOfRules);
  }

  tv.setText(text);
  tv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
      LayoutParams.FILL_PARENT));
  tv.setGravity(Gravity.CENTER_VERTICAL);
  tv.setPadding(10, 0, 0, 0);
  tv.setTextSize(14.0f);
  tv.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
  tv.setTextColor(context.getResources().getColor(R.color.list_element_text));
  tv.setMinHeight(46);

  ll.addView(iv);
  ll.addView(tv);

  return ll;
}
 
Example 17
Source Project: LibreTasks   File: AdapterRule.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Generates a single item in the listview tree widget.
 */
public View getView(int position, View convertView, ViewGroup parent) {

  NodeWrapper it = getNodeWrapper(position);

  LinearLayout ll = new LinearLayout(context);
  ll.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
      LayoutParams.FILL_PARENT));
  ll.setMinimumHeight(50);
  ll.setOrientation(LinearLayout.HORIZONTAL);
  ll.setGravity(Gravity.CENTER_VERTICAL);

  ImageView iv = new ImageView(context);
  iv.setImageResource(it.getNode().getItem().getIconResId());
  iv.setAdjustViewBounds(true);
  iv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.WRAP_CONTENT,
      LayoutParams.WRAP_CONTENT));
  if (listView.getCheckedItemPosition() == position) {
    iv.setBackgroundResource(R.drawable.icon_hilight);
  }

  TextView tv = new TextView(context);
  tv.setText(it.getNode().getItem().getDescriptionShort());
  tv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
      LayoutParams.FILL_PARENT));
  tv.setGravity(Gravity.CENTER_VERTICAL);
  tv.setPadding(10, 0, 0, 0);
  tv.setTextSize(14.0f);
  tv.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
  tv.setTextColor(context.getResources().getColor(R.color.list_element_text));
  tv.setMinHeight(46);

  // This is where we figure out which tree branch graphics to stack
  // to the left of a node to give the appearance of a real tree widget.
  ArrayList<Integer> branches = it.getBranches();
  for (int i = 0; i < branches.size(); i++) {
    int imageResourceId;
    if (i == branches.size() - 1) {
      // You are whatever I say you are.
      imageResourceId = branches.get(i).intValue();
    } else {
      // Here we do replacements.
      if (branches.get(i).intValue() == R.drawable.treebranch_child_end) {
        // empty png
        imageResourceId = R.drawable.treebranch_parent_empty;
      } else {
        // straight pipe png
        imageResourceId = R.drawable.treebranch_parent;
      }
    }

    ImageView ivBranch = new ImageView(context);
    ivBranch.setImageResource(imageResourceId);
    ivBranch.setAdjustViewBounds(true);
    ivBranch.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.WRAP_CONTENT,
        LayoutParams.WRAP_CONTENT));
    ll.addView(ivBranch);
  }

  ll.addView(iv);
  ll.addView(tv);
  return ll;
}
 
Example 18
/**
 * 构建内容视图 - IOS
 * @return 内容视图
 */
@SuppressWarnings("deprecation")
private View createContentViewForIOS(){
	//根布局
	rootLayout = new LinearLayout(context);
	rootLayout.setLayoutParams(getParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
	rootLayout.setOrientation(LinearLayout.VERTICAL);
	rootLayout.setBackgroundColor(Color.parseColor("#77000000"));
	rootLayout.setGravity(Gravity.BOTTOM);
	
	parentLayout = new LinearLayout(context);
	parentLayout.setLayoutParams(getParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	parentLayout.setOrientation(LinearLayout.VERTICAL);
	parentLayout.setBackgroundColor(Color.parseColor("#00000000"));
	
	LinearLayout childLayout = new LinearLayout(context);
	LayoutParams childParams = getParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	childParams.setMargins(8 * DP, 0, 8 * DP, 0);
	childLayout.setLayoutParams(childParams);
	childLayout.setOrientation(LinearLayout.VERTICAL);
	childLayout.setBackgroundDrawable(UEImage.createBackground(Color.WHITE, 204, 10));
	
	//标题
	TextView titleTextView = new TextView(context);
	titleTextView.setLayoutParams(getParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	titleTextView.setPadding(0, 10 * DP, 0, 10 * DP);
	titleTextView.setMinHeight(45 * DP);
	titleTextView.setTextSize(14);
	titleTextView.setGravity(Gravity.CENTER);
	titleTextView.setTextColor(Color.parseColor("#8F8F8F"));
	if (title == null) {
		titleTextView.setVisibility(View.GONE);
	}else{
		titleTextView.setVisibility(View.VISIBLE);
		titleTextView.setText(title);
	}
	
	//内容外层布局
	sheetLayout = new ScrollView(context);
	sheetLayout.setLayoutParams(getParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	sheetLayout.setFadingEdgeLength(0);
	
	//内容内层布局
	contentLayout = new LinearLayout(context);
	contentLayout.setLayoutParams(getParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	contentLayout.setOrientation(LinearLayout.VERTICAL);
	sheetLayout.addView(contentLayout);
	
	//取消按钮
	final TextView cancelTextView = new TextView(context);
	LayoutParams params = getParams(LayoutParams.MATCH_PARENT, 45 * DP);
	params.setMargins(8 * DP, 8 * DP, 8 * DP, 8 * DP);
	cancelTextView.setLayoutParams(params);
	cancelTextView.setTextColor(Color.parseColor("#3DB399"));
	cancelTextView.setTextSize(16);
	cancelTextView.setGravity(Gravity.CENTER);
	cancelTextView.setText("取消");
	cancelTextView.setBackgroundDrawable(UEImage.createBackground(Color.WHITE, 204, 10));
	cancelTextView.setOnClickListener(new OnClickListener() {
		
		@Override
		public void onClick(View arg0) {
			dismiss();
		}
	});
	
	//控件创建结束
	childLayout.addView(titleTextView);
	childLayout.addView(sheetLayout);
	parentLayout.addView(childLayout);
	parentLayout.addView(cancelTextView);
	rootLayout.addView(parentLayout);
	if (typeface != null) {
		titleTextView.setTypeface(typeface);
		cancelTextView.setTypeface(typeface);
	}
	return rootLayout;
}
 
Example 19
/**
 * 构建内容视图 - ANDROID
 * @return 内容视图
 */
private View createContentViewForANDROID(){
	//根布局
	rootLayout = new LinearLayout(context);
	rootLayout.setLayoutParams(getParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
	rootLayout.setOrientation(LinearLayout.VERTICAL);
	rootLayout.setBackgroundColor(Color.parseColor("#55000000"));
	rootLayout.setGravity(Gravity.BOTTOM);
	
	parentLayout = new LinearLayout(context);
	parentLayout.setLayoutParams(getParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	parentLayout.setOrientation(LinearLayout.VERTICAL);
	parentLayout.setBackgroundColor(backgroundColor);
	
	LinearLayout childLayout = new LinearLayout(context);
	LayoutParams childParams = getParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	childLayout.setLayoutParams(childParams);
	childLayout.setOrientation(LinearLayout.VERTICAL);
	
	//标题
	TextView titleTextView = new TextView(context);
	titleTextView.setLayoutParams(getParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	titleTextView.setMinHeight(48 * DP);
	titleTextView.setTextSize(12);
	titleTextView.setGravity(Gravity.CENTER);
	titleTextView.setTextColor(titleColor);
	if (title == null) {
		titleTextView.setVisibility(View.GONE);
	}else{
		titleTextView.setVisibility(View.VISIBLE);
		titleTextView.setText(title);
	}
	
	//内容外层布局
	sheetLayout = new ScrollView(context);
	sheetLayout.setLayoutParams(getParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	sheetLayout.setFadingEdgeLength(0);
	
	//内容内层布局
	contentLayout = new LinearLayout(context);
	contentLayout.setLayoutParams(getParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	contentLayout.setOrientation(LinearLayout.VERTICAL);
	sheetLayout.addView(contentLayout);
	
	//取消按钮
	final TextView cancelTextView = new TextView(context);
	LayoutParams params = getParams(LayoutParams.MATCH_PARENT, 52 * DP);
	params.setMargins(0, 8 * DP, 0, 0);
	cancelTextView.setLayoutParams(params);
	cancelTextView.setTextColor(cancelColor);
	cancelTextView.setTextSize(16);
	cancelTextView.setGravity(Gravity.CENTER);
	cancelTextView.setText("取消");
	cancelTextView.setBackgroundColor(itemBackgroundColor);
	cancelTextView.setOnClickListener(new OnClickListener() {
		
		@Override
		public void onClick(View arg0) {
			dismiss();
		}
	});
	
	//控件创建结束
	childLayout.addView(titleTextView);
	childLayout.addView(sheetLayout);
	parentLayout.addView(childLayout);
	parentLayout.addView(cancelTextView);
	rootLayout.addView(parentLayout);
	if (typeface != null) {
		titleTextView.setTypeface(typeface);
		cancelTextView.setTypeface(typeface);
	}
	return rootLayout;
}