Java Code Examples for android.widget.TextView#setId()
The following examples show how to use
android.widget.TextView#setId() .
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: ListWidget.java From commcare-android with Apache License 2.0 | 7 votes |
@Override protected void addQuestionText() { // Add the text view. Textview always exists, regardless of whether there's text. TextView questionText = new TextView(getContext()); setQuestionText(questionText, mPrompt); questionText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, TEXTSIZE); questionText.setTypeface(null, Typeface.BOLD); questionText.setPadding(0, 0, 0, 7); questionText.setId(buttonIdBase); // assign random id // Wrap to the size of the parent view questionText.setHorizontallyScrolling(false); if (mPrompt.getLongText() == null) { questionText.setVisibility(GONE); } // Put the question text on the left half of the screen LinearLayout.LayoutParams labelParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); labelParams.weight = 1; questionLayout = new LinearLayout(getContext()); questionLayout.setOrientation(LinearLayout.HORIZONTAL); questionLayout.addView(questionText, labelParams); }
Example 2
Source File: InstallActivity.java From javainstaller with GNU General Public License v3.0 | 6 votes |
public LinearLayout makell(int id){ LinearLayout ll = new LinearLayout(this); ll.setOrientation(LinearLayout.VERTICAL); TextView tv = new TextView(this); tv.setText(((uninstall)?"uninstalling ":"installing ")+MainActivity.checks[id].text); ll.addView(tv); if(!uninstall){ ProgressBar pb = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal); pb.setId(1); pb.setProgress(0); pb.setMax(100); ll.addView(pb); TextView tv1 = new TextView(this); tv1.setId(2); tv1.setText("0/0kb 0/100%"); ll.addView(tv1); } return ll; }
Example 3
Source File: PinViewBaseHelper.java From nono-android with GNU General Public License v3.0 | 5 votes |
/** * Generate a Split {@link TextView} with all attributes to add to {@link PinView} * * @param i index of new split * @return new split */ TextView generateSplit(int i) { TextView split = new TextView(getContext()); int generateViewId = PinViewUtils.generateViewId(); split.setId(generateViewId); setStylesSplit(split); pinSplitsIds[i] = generateViewId; return split; }
Example 4
Source File: SeekBarPreference.java From DistroHopper with GNU General Public License v3.0 | 5 votes |
/** * Create progress bar and other view contents. */ protected View onCreateView (ViewGroup p) { final Context ctx = getContext(); LinearLayout layout = new LinearLayout( ctx ); layout.setId( android.R.id.widget_frame ); layout.setOrientation (LinearLayout.VERTICAL); layout.setPadding (15, 15, 15, 15); TextView title = new TextView( ctx ); title.setId (android.R.id.title); title.setSingleLine (); title.setTextAppearance (ctx, android.R.style.TextAppearance_Medium); layout.addView( title ); seekbar = new SeekBar( ctx ); seekbar.setId( android.R.id.progress ); seekbar.setMax (max); seekbar.setProgress (this.defaultValue); seekbar.setOnSeekBarChangeListener( this ); layout.addView( seekbar ); summary = new TextView( ctx ); summary.setId (android.R.id.summary); summary.setTextAppearance (ctx, android.R.style.TextAppearance_Small); layout.addView( summary ); return layout; }
Example 5
Source File: CustomActivity.java From MultipleStatusView with MIT License | 5 votes |
private TextView createCustomView(String text) { TextView tv = new TextView(getApplicationContext()); tv.setId(Utils.generateViewId()); tv.setText(text); tv.setGravity(Gravity.CENTER); //noinspection deprecation tv.setTextColor(getResources().getColor(R.color.color_item_intro)); return tv; }
Example 6
Source File: RecyclerFragment.java From AndroidDigIn with Apache License 2.0 | 5 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { final Context context = getContext(); FrameLayout root = new FrameLayout(context); // ------------------------------------------------------------------ mRecyclerContainer = new FrameLayout(context); mRecyclerContainer.setId(R.id.recycler_container_id); mStandardEmptyView = new TextView(context); mStandardEmptyView.setId(R.id.recycler_empty_id); mStandardEmptyView.setGravity(Gravity.CENTER); mStandardEmptyView.setVisibility(View.GONE); mRecyclerContainer.addView(mStandardEmptyView, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mRecyclerView = new RecyclerView(context); mRecyclerView.setId(R.id.recycler); mRecyclerContainer.addView(mRecyclerView, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); root.addView(mRecyclerContainer, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); // ------------------------------------------------------------------ root.setLayoutParams(new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); return root; }
Example 7
Source File: PinViewBaseHelper.java From nono-android with GNU General Public License v3.0 | 5 votes |
/** * Generate a Title {@link TextView} with all attributes to add to {@link PinView} * * @param i index of new Title * @return new title */ TextView generatePinText(int i, String[] titles) { TextView pinTitle = (TextView) LayoutInflater.from(getContext()) .inflate(R.layout.partial_pin_text, this, false); int generateViewId = PinViewUtils.generateViewId(); pinTitle.setId(generateViewId); pinTitle.setText(titles[i]); setStylesPinTitle(pinTitle); pinTitlesIds[i] = generateViewId; return pinTitle; }
Example 8
Source File: Crouton.java From TiCrouton with MIT License | 5 votes |
private TextView initializeTextView(final Resources resources) { TextView text = new TextView(this.activity); text.setId(TEXT_ID); text.setText(this.text); text.setTypeface(Typeface.DEFAULT_BOLD); text.setGravity(this.style.gravity); // set the text color if set if (this.style.textColorValue != Style.NOT_SET) { text.setTextColor(this.style.textColorValue); } else if (this.style.textColorResourceId != 0) { text.setTextColor(resources.getColor(this.style.textColorResourceId)); } // Set the text size. If the user has set a text size and text // appearance, the text size in the text appearance // will override this. if (this.style.textSize != 0) { text.setTextSize(TypedValue.COMPLEX_UNIT_SP, this.style.textSize); } // Setup the shadow if requested if (this.style.textShadowColorResId != 0) { initializeTextViewShadow(resources, text); } // Set the text appearance if (this.style.textAppearanceResId != 0) { text.setTextAppearance(this.activity, this.style.textAppearanceResId); } return text; }
Example 9
Source File: IconButtonView.java From PinyinSearchLibrary with Apache License 2.0 | 5 votes |
private void initView(boolean hideIcon){ this.removeAllViews(); mTitleTv = new TextView(mContext); mTitleTv.setId(TITLE_TEXT_VIEW_ID); // mTitleTv.setTextSize(mContext.getResources().getDimension(R.dimen.tab_index_text_size)); mTitleTv.setGravity(Gravity.CENTER); LayoutParams titleTvLp = new LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); titleTvLp.addRule(RelativeLayout.CENTER_VERTICAL); titleTvLp.addRule(RelativeLayout.CENTER_HORIZONTAL); this.addView(mTitleTv, titleTvLp); mIconIv = new ImageView(mContext); int layoutWidth = (int) mContext.getResources().getDimension( R.dimen.tab_index_icon_width); int layoutHeight = (int) mContext.getResources().getDimension( R.dimen.tab_index_icon_height); /* * int layoutWidth= LayoutParams.WRAP_CONTENT; * intlayoutHeight=LayoutParams.WRAP_CONTENT; */ LayoutParams iconIvLp = new LayoutParams( layoutWidth, layoutHeight); iconIvLp.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); iconIvLp.addRule(RelativeLayout.ABOVE, mTitleTv.getId()); if(hideIcon){ iconIvLp.addRule(GONE); }else{ iconIvLp.addRule(VISIBLE); } this.addView(mIconIv,iconIvLp); return; }
Example 10
Source File: QuestionWidget.java From commcare-android with Apache License 2.0 | 5 votes |
/** * Add a Views containing the question text, audio (if applicable), and image (if applicable). * To satisfy the RelativeLayout constraints, we add the audio first if it exists, then the * TextView to fit the rest of the space, then the image if applicable. */ protected void addQuestionText() { mQuestionText = (TextView)LayoutInflater.from(getContext()).inflate(getQuestionTextLayout(), this, false); mQuestionText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mQuestionFontSize); mQuestionText.setId(38475483); // assign random id setQuestionText(mQuestionText, mPrompt); if (mPrompt.getLongText() != null) { if (mPrompt.getLongText().contains("\u260E")) { if (Linkify.addLinks(mQuestionText, Linkify.PHONE_NUMBERS)) { stripUnderlines(mQuestionText); } else { Log.d(TAG, "this should be an error I'm thinking?"); } } } if (mPrompt.getLongText() == null) { mQuestionText.setVisibility(GONE); } if (isInCompactMode()) { addToCompactLayout(mQuestionText); } else { // Create the layout for audio, image, text String imageURI = mPrompt.getImageText(); String audioURI = mPrompt.getAudioText(); String videoURI = mPrompt.getSpecialFormQuestionText("video"); String inlineVideoUri = mPrompt.getSpecialFormQuestionText("video-inline"); String qrCodeContent = mPrompt.getSpecialFormQuestionText("qrcode"); // shown when image is clicked String bigImageURI = mPrompt.getSpecialFormQuestionText("big-image"); MediaLayout mediaLayout = MediaLayout.buildComprehensiveLayout(getContext(), mQuestionText, audioURI, imageURI, videoURI, bigImageURI, qrCodeContent, inlineVideoUri, mPrompt.getIndex().hashCode()); addView(mediaLayout, mLayout); } }
Example 11
Source File: SupportCursorAdapterTest.java From arca-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void testItemCursorAdapterDefaultViewBinding() { final TextView child1 = new TextView(getContext()); child1.setId(R.id.test_id_1); final FrameLayout container = new FrameLayout(getContext()); container.addView(child1); final String[] columns = new String[] { "_id" }; final Cursor cursor = createCursor(columns); final Collection<Binding> bindings = createBindings(columns); final SupportCursorAdapter adapter = new SupportCursorAdapter(getContext(), -1, bindings); adapter.bindView(container, getContext(), cursor); assertEquals("default_test", child1.getText()); }
Example 12
Source File: OAuthDialogFragment.java From mirror with Apache License 2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View customLayout = mController.onCreateView(inflater, container, savedInstanceState); if (customLayout != null) { return customLayout; } final Context context = inflater.getContext(); FrameLayout root = new FrameLayout(context); root.setLayoutParams(new LayoutParams(MATCH_PARENT, MATCH_PARENT)); WebView wv = new WebView(context); wv.setId(android.R.id.primary); root.addView(wv, new LayoutParams(MATCH_PARENT, MATCH_PARENT)); LinearLayout pframe = new LinearLayout(context); pframe.setId(android.R.id.widget_frame); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setVisibility(View.GONE); pframe.setGravity(Gravity.CENTER); ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge); progress.setId(android.R.id.progress); pframe.addView(progress, new LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); TextView progressText = new TextView(context, null, android.R.attr.textViewStyle); progressText.setId(android.R.id.text1); pframe.addView(progressText, new LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); root.addView(pframe, new LayoutParams(MATCH_PARENT, MATCH_PARENT)); return root; }
Example 13
Source File: FieldAnnotationParserTest.java From easy-adapter with Apache License 2.0 | 5 votes |
@SuppressWarnings("ResourceType") //Because of warning when setting a hardcoded ID into the view private static LinearLayout createTestLinearLayout() { LinearLayout linearLayout = new LinearLayout(RuntimeEnvironment.application); TextView textView = new TextView(RuntimeEnvironment.application); textView.setId(TEXT_VIEW_ID); linearLayout.addView(textView); ImageView imageView = new ImageView(RuntimeEnvironment.application); imageView.setId(IMAGE_VIEW_ID); linearLayout.addView(imageView); return linearLayout; }
Example 14
Source File: HelpActivity.java From Noyze with Apache License 2.0 | 4 votes |
/** * Generates our layout in-code. Only called once, then * we'll be sure to recycle these {@link View}s. */ public final View makeLayout() { // Layout Parameters. DisplayMetrics dm = new DisplayMetrics(); WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); wm.getDefaultDisplay().getMetrics(dm); final int[] mWindowDims = new int[] { dm.widthPixels, dm.heightPixels }; final int mWindowWidth = mWindowDims[0], mMaxWidth = mContext.getResources().getDimensionPixelSize(R.dimen.max_menu_width); final int gutter = mContext.getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin); final FrameLayout.LayoutParams mParams = new FrameLayout.LayoutParams( ((mWindowWidth > mMaxWidth) ? mMaxWidth : android.view.ViewGroup.LayoutParams.MATCH_PARENT), android.view.ViewGroup.LayoutParams.MATCH_PARENT); final RelativeLayout.LayoutParams mTextParams = new RelativeLayout.LayoutParams( android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT); mTextParams.addRule(RelativeLayout.CENTER_IN_PARENT); mParams.gravity = Gravity.CENTER; // Main text and image. final TextView text = new TextView(mContext); text.setTextColor(Color.DKGRAY); text.setId(R.id.help_text); text.setLayoutParams(mTextParams); text.setGravity(Gravity.CENTER_HORIZONTAL); text.setMovementMethod(LinkMovementMethod.getInstance()); text.setLinksClickable(true); final int mTextSize = mContext.getResources() .getDimensionPixelSize(R.dimen.help_text_size); text.setTextSize(mTextSize); text.setCompoundDrawablePadding((gutter/2)); text.setPadding(gutter, gutter, gutter, gutter); // Allow the View to Scroll vertically if necessary. final ScrollView scroll = new ScrollView(mContext); scroll.setLayoutParams(mParams); scroll.setFillViewport(true); scroll.setSmoothScrollingEnabled(true); scroll.setVerticalScrollBarEnabled(false); final RelativeLayout layout = new RelativeLayout(mContext); mParams.topMargin = mParams.bottomMargin = mContext.getResources().getDimensionPixelSize(R.dimen.activity_vertical_margin); mParams.leftMargin = mParams.rightMargin = mContext.getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin); layout.setLayoutParams(mParams); layout.addView(text); scroll.addView(layout); return scroll; }
Example 15
Source File: ListFragment.java From android-recipes-app with Apache License 2.0 | 4 votes |
/** * Provide default implementation to return a simple list view. Subclasses * can override to replace with their own layout. If doing so, the * returned view hierarchy <em>must</em> have a ListView whose id * is {@link android.R.id#list android.R.id.list} and can optionally * have a sibling view id {@link android.R.id#empty android.R.id.empty} * that is to be shown when the list is empty. * * <p>If you are overriding this method with your own custom content, * consider including the standard layout {@link android.R.layout#list_content} * in your layout file, so that you continue to retain all of the standard * behavior of ListFragment. In particular, this is currently the only * way to have the built-in indeterminant progress state be shown. */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Context context = getActivity(); FrameLayout root = new FrameLayout(context); // ------------------------------------------------------------------ LinearLayout pframe = new LinearLayout(context); pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setVisibility(View.GONE); pframe.setGravity(Gravity.CENTER); ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge); pframe.addView(progress, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); root.addView(pframe, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); // ------------------------------------------------------------------ FrameLayout lframe = new FrameLayout(context); lframe.setId(INTERNAL_LIST_CONTAINER_ID); TextView tv = new TextView(getActivity()); tv.setId(INTERNAL_EMPTY_ID); tv.setGravity(Gravity.CENTER); lframe.addView(tv, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); ListView lv = new ListView(getActivity()); lv.setId(android.R.id.list); lv.setDrawSelectorOnTop(false); lframe.addView(lv, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); root.addView(lframe, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); // ------------------------------------------------------------------ root.setLayoutParams(new FrameLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); return root; }
Example 16
Source File: AdpArtworks.java From freemp with Apache License 2.0 | 4 votes |
@Override public View getView(int position, View view, ViewGroup parent) { if (view == null) { final RelativeLayout rl = new RelativeLayout(activity); rl.setLayoutParams(layoutParams); final ImageView img = new ImageView(activity); RelativeLayout.LayoutParams imglp = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.MATCH_PARENT); img.setPadding(10, 10, 0, 0); img.setId(imgid); //img.setLayoutParams(layoutParams); rl.addView(img,imglp); TextView tv = new TextView(activity); //tv.setSingleLine(); tv.setPadding(16,0,40,0); RelativeLayout.LayoutParams lptv = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); lptv.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, img.getId()); tv.setShadowLayer(1,-2,-2, Color.BLACK); tv.setId(tvid); rl.addView(tv,lptv); view = rl; } AQuery aq = listAq.recycle(view); final ClsTrack track = data.get(position); if (aq.shouldDelay(position, view, parent, "" + track.getAlbumId())) { aq.id(imgid).image(R.drawable.row_bgr); } else { aq.id(imgid).image(MediaUtils.getArtworkQuick(activity, track, 300, 300)).animate(fadeIn); } aq.id(tvid).getTextView().setText((""+track.getArtist())); return view; }
Example 17
Source File: OverviewActivity.java From privacy-friendly-food-tracker with GNU General Public License v3.0 | 4 votes |
/** * Creates a CheckedCardView from the entry * * @param e * @return */ private CardView createCardViewForEntry(DatabaseEntry e) { // set up CardView for entry CheckableCardView c = new CheckableCardView(this); setCardViewOptions(c); // set up Layout that gets used inside the CardView ConstraintLayout cl = new ConstraintLayout(this); ConstraintSet set = new ConstraintSet(); // set up Textviews for cards TextView name = new TextView(this); name.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.slide_actions)); TextView amount = new TextView(this); TextView energy = new TextView(this); TextView calories = new TextView(this); calories.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.slide_actions)); TextView id = new TextView(this); // Each CardView needs an ID to reference in the ConstraintText name.setId(View.generateViewId()); amount.setId(View.generateViewId()); energy.setId(View.generateViewId()); calories.setId(View.generateViewId()); id.setText(e.id); name.setText(e.name); amount.setText(Integer.toString(e.amount) + "g"); energy.setText(String.format(Locale.ENGLISH, " %.2f kCal/100g", e.energy)); calories.setText(String.format(Locale.ENGLISH, "%.2f kCal", getConsumedCaloriesForEntry(e))); // id is just an invisible attribute on each card id.setVisibility(View.INVISIBLE); set.constrainWidth(amount.getId(), ConstraintSet.WRAP_CONTENT); set.constrainHeight(amount.getId(), ConstraintSet.WRAP_CONTENT); set.constrainWidth(energy.getId(), ConstraintSet.WRAP_CONTENT); set.constrainHeight(energy.getId(), ConstraintSet.WRAP_CONTENT); set.constrainWidth(calories.getId(), ConstraintSet.WRAP_CONTENT); cl.addView(name); cl.addView(calories); cl.addView(amount); cl.addView(energy); c.addView(cl); c.addView(id); set.connect(name.getId(), ConstraintSet.LEFT, ConstraintSet.PARENT_ID, ConstraintSet.LEFT, 20); set.connect(name.getId(), ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP, 20); set.connect(name.getId(), ConstraintSet.RIGHT, calories.getId(), ConstraintSet.LEFT, 40); set.constrainDefaultHeight(name.getId(), ConstraintSet.MATCH_CONSTRAINT_WRAP); set.connect(calories.getId(), ConstraintSet.RIGHT, ConstraintSet.PARENT_ID, ConstraintSet.RIGHT, 20); set.connect(calories.getId(), ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP, 20); set.constrainDefaultHeight(calories.getId(), ConstraintSet.MATCH_CONSTRAINT_WRAP); set.constrainDefaultWidth(calories.getId(), ConstraintSet.MATCH_CONSTRAINT_WRAP); set.connect(amount.getId(), ConstraintSet.TOP, name.getId(), ConstraintSet.BOTTOM, 20); set.connect(amount.getId(), ConstraintSet.RIGHT, ConstraintSet.PARENT_ID, ConstraintSet.RIGHT, 20); set.connect(amount.getId(), ConstraintSet.BOTTOM, ConstraintSet.PARENT_ID, ConstraintSet.BOTTOM, 20); set.connect(energy.getId(), ConstraintSet.TOP, name.getId(), ConstraintSet.BOTTOM, 20); set.connect(energy.getId(), ConstraintSet.LEFT, ConstraintSet.PARENT_ID, ConstraintSet.LEFT, 20); set.connect(energy.getId(), ConstraintSet.BOTTOM, ConstraintSet.PARENT_ID, ConstraintSet.BOTTOM, 20); set.applyTo(cl); setListenersForCardView(c, e); return c; }
Example 18
Source File: PaymentRequestSection.java From AndroidChromium with Apache License 2.0 | 4 votes |
/** * Creates the main section. Subclasses must call super#createMainSection() immediately to * guarantee that Views are added in the correct order. * * @param sectionName Title to display for the section. */ private LinearLayout prepareMainSection(String sectionName) { // The main section is a vertical linear layout that subclasses can append to. LinearLayout mainSectionLayout = new LinearLayout(getContext()); mainSectionLayout.setOrientation(VERTICAL); LinearLayout.LayoutParams mainParams = new LayoutParams(0, LayoutParams.WRAP_CONTENT); mainParams.weight = 1; addView(mainSectionLayout, mainParams); // The title is always displayed for the row at the top of the main section. mTitleView = new TextView(getContext()); mTitleView.setText(sectionName); ApiCompatibilityUtils.setTextAppearance( mTitleView, R.style.PaymentsUiSectionHeader); mainSectionLayout.addView( mTitleView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); // Create the two TextViews for showing the summary text. mSummaryLeftTextView = new TextView(getContext()); mSummaryLeftTextView.setId(R.id.payments_left_summary_label); ApiCompatibilityUtils.setTextAppearance( mSummaryLeftTextView, R.style.PaymentsUiSectionDefaultText); mSummaryRightTextView = new TextView(getContext()); ApiCompatibilityUtils.setTextAppearance( mSummaryRightTextView, R.style.PaymentsUiSectionDefaultText); ApiCompatibilityUtils.setTextAlignment(mSummaryRightTextView, TEXT_ALIGNMENT_TEXT_END); // The main TextView sucks up all the available space. LinearLayout.LayoutParams leftLayoutParams = new LinearLayout.LayoutParams( 0, LayoutParams.WRAP_CONTENT); leftLayoutParams.weight = 1; LinearLayout.LayoutParams rightLayoutParams = new LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); ApiCompatibilityUtils.setMarginStart( rightLayoutParams, getContext().getResources().getDimensionPixelSize( R.dimen.payments_section_small_spacing)); // The summary section displays up to two TextViews side by side. mSummaryLayout = new LinearLayout(getContext()); mSummaryLayout.addView(mSummaryLeftTextView, leftLayoutParams); mSummaryLayout.addView(mSummaryRightTextView, rightLayoutParams); mainSectionLayout.addView(mSummaryLayout, new LinearLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); setSummaryText(null, null); createMainSectionContent(mainSectionLayout); return mainSectionLayout; }
Example 19
Source File: ViewMaker.java From iGap-Android with GNU Affero General Public License v3.0 | 4 votes |
static View getViewForward() { LinearLayout cslr_ll_forward = new LinearLayout(context); cslr_ll_forward.setId(R.id.cslr_ll_forward); cslr_ll_forward.setClickable(true); cslr_ll_forward.setOrientation(HORIZONTAL); cslr_ll_forward.setPadding(i_Dp(R.dimen.messageContainerPaddingLeftRight), i_Dp(messageContainerPadding), i_Dp(R.dimen.messageContainerPaddingLeftRight), i_Dp(messageContainerPadding)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { cslr_ll_forward.setTextDirection(View.TEXT_DIRECTION_LOCALE); } setLayoutDirection(cslr_ll_forward, View.LAYOUT_DIRECTION_LOCALE); LinearLayout.LayoutParams layout_687 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); cslr_ll_forward.setLayoutParams(layout_687); View View_997 = new View(context); View_997.setBackgroundColor(Color.parseColor(G.textBubble)); LinearLayout.LayoutParams layout_547 = new LinearLayout.LayoutParams(dpToPixel(2), ViewGroup.LayoutParams.MATCH_PARENT); layout_547.rightMargin = dpToPixel(3); View_997.setLayoutParams(layout_547); cslr_ll_forward.addView(View_997); TextView cslr_txt_prefix_forward = new TextView(context); cslr_txt_prefix_forward.setId(R.id.cslr_txt_prefix_forward); cslr_txt_prefix_forward.setText(context.getResources().getString(R.string.forwarded_from)); cslr_txt_prefix_forward.setTextColor(Color.parseColor(G.textBubble)); setTextSize(cslr_txt_prefix_forward, R.dimen.dp12); cslr_txt_prefix_forward.setSingleLine(true); cslr_txt_prefix_forward.setTypeface(G.typeface_IRANSansMobile_Bold); LinearLayout.LayoutParams layout_992 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); layout_992.rightMargin = i_Dp(dp4); layout_992.leftMargin = i_Dp(R.dimen.dp6); cslr_txt_prefix_forward.setLayoutParams(layout_992); cslr_ll_forward.addView(cslr_txt_prefix_forward); TextView cslr_txt_forward_from = new TextView(context); cslr_txt_forward_from.setId(R.id.cslr_txt_forward_from); cslr_txt_forward_from.setMinimumWidth(i_Dp(R.dimen.dp100)); cslr_txt_forward_from.setMaxWidth(i_Dp(R.dimen.dp140)); cslr_txt_forward_from.setTextColor(Color.parseColor(G.textBubble)); setTextSize(cslr_txt_forward_from, R.dimen.dp12); cslr_txt_forward_from.setSingleLine(true); cslr_txt_forward_from.setTypeface(G.typeface_IRANSansMobile_Bold); LinearLayout.LayoutParams layout_119 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); cslr_txt_forward_from.setLayoutParams(layout_119); cslr_ll_forward.addView(cslr_txt_forward_from); return cslr_ll_forward; }
Example 20
Source File: PaymentRequestSection.java From 365browser with Apache License 2.0 | 4 votes |
/** * Creates the main section. Subclasses must call super#createMainSection() immediately to * guarantee that Views are added in the correct order. * * @param sectionName Title to display for the section. */ private LinearLayout prepareMainSection(String sectionName) { // The main section is a vertical linear layout that subclasses can append to. LinearLayout mainSectionLayout = new LinearLayout(getContext()); mainSectionLayout.setOrientation(VERTICAL); LinearLayout.LayoutParams mainParams = new LayoutParams(0, LayoutParams.WRAP_CONTENT); mainParams.weight = 1; addView(mainSectionLayout, mainParams); // The title is always displayed for the row at the top of the main section. mTitleView = new TextView(getContext()); mTitleView.setText(sectionName); ApiCompatibilityUtils.setTextAppearance( mTitleView, R.style.PaymentsUiSectionHeader); mainSectionLayout.addView( mTitleView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); // Create the two TextViews for showing the summary text. mSummaryLeftTextView = new TextView(getContext()); mSummaryLeftTextView.setId(R.id.payments_left_summary_label); ApiCompatibilityUtils.setTextAppearance( mSummaryLeftTextView, R.style.PaymentsUiSectionDefaultText); mSummaryRightTextView = new TextView(getContext()); ApiCompatibilityUtils.setTextAppearance( mSummaryRightTextView, R.style.PaymentsUiSectionDefaultText); ApiCompatibilityUtils.setTextAlignment(mSummaryRightTextView, TEXT_ALIGNMENT_TEXT_END); // The main TextView sucks up all the available space. LinearLayout.LayoutParams leftLayoutParams = new LinearLayout.LayoutParams( 0, LayoutParams.WRAP_CONTENT); leftLayoutParams.weight = 1; LinearLayout.LayoutParams rightLayoutParams = new LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); ApiCompatibilityUtils.setMarginStart( rightLayoutParams, getContext().getResources().getDimensionPixelSize( R.dimen.payments_section_small_spacing)); // The summary section displays up to two TextViews side by side. mSummaryLayout = new LinearLayout(getContext()); mSummaryLayout.addView(mSummaryLeftTextView, leftLayoutParams); mSummaryLayout.addView(mSummaryRightTextView, rightLayoutParams); mainSectionLayout.addView(mSummaryLayout, new LinearLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); setSummaryText(null, null); createMainSectionContent(mainSectionLayout); return mainSectionLayout; }