List of usage examples for android.widget RelativeLayout TRUE
int TRUE
To view the source code for android.widget RelativeLayout TRUE.
Click Source Link
From source file:com.goldcard.igas.widget.tabindicator.TabPageIndicator.java
private void addTab(int index, CharSequence text, int iconResId) { final TabView tabView = new TabView(getContext()); tabView.mIndex = index;//from www . j a v a 2s .c o m tabView.setGravity(Gravity.CENTER); tabView.setFocusable(true); tabView.setOnClickListener(mTabClickListener); tabView.setText(text); if (iconResId != 0) { tabView.setCompoundDrawablesWithIntrinsicBounds(iconResId, 0, 0, 0); } RelativeLayout rr = new RelativeLayout(this.getContext()); rr.setGravity(Gravity.CENTER); rr.setFocusable(true); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); lp.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); tabView.setLayoutParams(lp); rr.addView(tabView); mTabLayout.addView(rr, new LinearLayout.LayoutParams(0, MATCH_PARENT, 1)); }
From source file:de.mrapp.android.view.FloatingActionButton.java
/** * Inflates the view's layout./*from w w w .j ava2 s. co m*/ */ private void inflateLayout() { imageButton = new ImageButton(getContext()); LayoutParams layoutParams = new LayoutParams(0, 0); layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); addView(imageButton, layoutParams); }
From source file:com.discord.chipsview.ChipsView.java
private void init() { mDensity = getResources().getDisplayMetrics().density; mChipsContainer = new RelativeLayout(getContext()); addView(mChipsContainer);/*w w w . jav a 2 s . c o m*/ // Dummy item to prevent AutoCompleteTextView from receiving focus LinearLayout linearLayout = new LinearLayout(getContext()); ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(0, 0); linearLayout.setLayoutParams(params); linearLayout.setFocusable(true); linearLayout.setFocusableInTouchMode(true); mChipsContainer.addView(linearLayout); mEditText = new ChipsEditText(getContext(), this); final int chipHeightWithPadding = (int) ((CHIP_HEIGHT * mDensity) + mVerticalSpacing); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, chipHeightWithPadding); layoutParams.leftMargin = (int) (5 * mDensity); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); mEditText.setLayoutParams(layoutParams); mEditText.setPadding(0, 0, 0, mVerticalSpacing); mEditText.setBackgroundColor(Color.argb(0, 0, 0, 0)); mEditText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); mEditText.setInputType(InputType.TYPE_CLASS_TEXT); mEditText.setTextColor(mChipsSearchTextColor); mEditText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mChipsSearchTextSize); mChipsContainer.addView(mEditText); mRootChipsLayout = new ChipsVerticalLinearLayout(getContext(), chipHeightWithPadding); mRootChipsLayout.setOrientation(LinearLayout.VERTICAL); mRootChipsLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); mRootChipsLayout.setPadding(0, (int) (SPACING_TOP * mDensity), 0, 0); mChipsContainer.addView(mRootChipsLayout); initListener(); onChipsChanged(false); }
From source file:com.github.yggie.pulltorefresh.PullListFragment.java
/** * Called to do initial creation of the fragment. Creates all the Views in code * * @param inflater The LayoutInflater//from ww w .j a v a2s. co m * @param container The parent container * @param savedInstanceState The saved pullState * @return The inflated view */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Context context = getActivity(); // setup the list view listView = new CustomListView(this); listView.setId(ID_LIST_VIEW); final RelativeLayout.LayoutParams listViewParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); listViewParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); listViewParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); listView.setLayoutParams(listViewParams); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { onListItemClick((ListView) adapterView, view, position, id); } }); // setup the empty view final TextView textView = new TextView(context); textView.setLayoutParams(listViewParams); textView.setGravity(Gravity.CENTER); textView.setText("Nothing to show"); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18.0f); emptyView = textView; emptyView.setId(ID_EMPTY_VIEW); // setup top pulled view final RelativeLayout.LayoutParams topViewParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); topViewParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); topViewParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); final FrameLayout topFrameLayout = new FrameLayout(context); topFrameLayout.setLayoutParams(topViewParams); // setup the default child of the FrameLayout topManager = new DefaultPulledView(this, true); topFrameLayout.addView(topManager); topPulledView = topFrameLayout; topPulledView.setId(ID_TOP_VIEW); // setup bottom pulled view final RelativeLayout.LayoutParams bottomViewParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); bottomViewParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); bottomViewParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); final FrameLayout bottomFrameLayout = new FrameLayout(context); bottomFrameLayout.setLayoutParams(bottomViewParams); // setup the default child in the FrameLayout bottomManager = new DefaultPulledView(this, false); bottomFrameLayout.addView(bottomManager); bottomPulledView = bottomFrameLayout; bottomPulledView.setId(ID_BOTTOM_VIEW); layout = new PullToRefreshLayout(this); layout.addView(topPulledView); layout.addView(bottomPulledView); layout.addView(listView); layout.addView(emptyView); layout.setId(ID_LAYOUT); listShown = false; listView.setVisibility(View.GONE); emptyView.setVisibility(View.VISIBLE); // applies the XML attributes, if exists if (attrs != null) { final TypedArray a = getActivity().obtainStyledAttributes(attrs, R.styleable.PullListFragment); if (a != null) { parseXmlAttributes(a); a.recycle(); } attrs = null; } return layout; }
From source file:com.derrick.movies.MovieDetailsActivity.java
private void setTrailers(Videos videos) { videosList = videos.getResults();/*from w w w. ja v a 2s.com*/ int size = videosList.size(); if (size == 1) { txt_title_trailer.setText("Trailer"); } for (int i = 0; i < size; i++) { Result result = videosList.get(i); String url = IMAGE_YOUTUBE + result.getKey() + YOUTUBE_QUALITY; ImageView imageView; ImageView imageView_play; TextView txt_name; ViewGroup.LayoutParams lp = new RelativeLayout.LayoutParams(70, 70); ViewGroup.LayoutParams lp2 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); RelativeLayout relativeLayout = new RelativeLayout(this); relativeLayout.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); if (size == 1) { imageView = new ImageView(getApplicationContext()); imageView.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); } else { imageView = new ImageView(getApplicationContext()); imageView .setLayoutParams(new RelativeLayout.LayoutParams(500, ViewGroup.LayoutParams.MATCH_PARENT)); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); } imageView_play = new ImageView(getApplicationContext()); imageView_play.setLayoutParams(lp); RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) imageView_play .getLayoutParams(); layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); imageView_play.setLayoutParams(layoutParams); imageView_play.setScaleType(ImageView.ScaleType.CENTER_CROP); Drawable drawable = getResources() .getDrawable(getResources().getIdentifier("play", "drawable", getPackageName())); imageView_play.setImageDrawable(drawable); txt_name = new TextView(getApplicationContext()); txt_name.setLayoutParams(lp2); RelativeLayout.LayoutParams layoutParams2 = (RelativeLayout.LayoutParams) txt_name.getLayoutParams(); layoutParams2.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); layoutParams2.setMargins(8, 8, 8, 16); txt_name.setLayoutParams(layoutParams2); txt_name.setTypeface(robotoCondensed); txt_name.setText(result.getName()); txt_name.setTextColor(getResources().getColor(R.color.colorWhite)); Glide.with(getBaseContext()).load(url).diskCacheStrategy(DiskCacheStrategy.ALL) .listener(new RequestListener<String, GlideDrawable>() { @Override public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) { return false; } @Override public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) { return false; } }).into(imageView); // trailerSlider.addView(imageView_play); relativeLayout.addView(imageView); relativeLayout.addView(imageView_play); relativeLayout.addView(txt_name); trailerSlider.addView(relativeLayout); } }
From source file:org.odk.collect.android.widgets.QuestionWidget.java
protected void addQuestionMediaLayout(View v) { if (v == null) { Timber.e("cannot add a null view as questionMediaLayout"); return;/*www.ja va 2 s.co m*/ } // default for questionmedialayout RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); params.setMargins(10, 0, 10, 0); addView(v, params); }
From source file:org.odk.collect.android.widgets.QuestionWidget.java
/** * Add a TextView containing the help text to the default location. * Override to reposition./*from w ww .j av a2 s. com*/ */ protected void addHelpTextView(View v) { if (v == null) { Timber.e("cannot add a null view as helpTextView"); return; } // default for helptext RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); params.addRule(RelativeLayout.BELOW, questionMediaLayout.getId()); params.setMargins(10, 0, 10, 0); addView(v, params); }
From source file:com.pdftron.pdf.controls.UserCropDialogFragment.java
private void initUI(final View view) { final FrameLayout layout = (FrameLayout) view.findViewById(R.id.layout_root); mPageNumberTextView = (TextView) view.findViewById(R.id.page_num_text_view); mLayoutName = layout.getTag().toString(); mDisablingOverlay = view.findViewById(R.id.disabling_overlay); mProgressBarHost = view.findViewById(R.id.progress_bar_host); mDisablingOverlay.setOnTouchListener(new View.OnTouchListener() { @Override/*from w w w. j a v a 2 s . c o m*/ public boolean onTouch(View v, MotionEvent event) { return true; // ensure the user can't click buttons } }); mCropPageHost = (RelativeLayout) view.findViewById(R.id.page_crop_host); mCropImageBorder = view.findViewById(R.id.image_crop_border); mCropImageView = (com.edmodo.cropper.CropImageView) view.findViewById(R.id.image_crop_view); mCropImageView.setGuidelines(0); // off mCropImageBorder.setVisibility(View.GONE); mBlankPagePlaceholder = view.findViewById(R.id.blank_page_placeholder); mBlankPageSpinnerHost = (ContentLoadingRelativeLayout) view.findViewById(R.id.blank_page_progress_bar_host); if (mRemoveCropHelperMode) { View manualCropRoot = view.findViewById(R.id.manual_crop_root_layout); manualCropRoot.setVisibility(View.GONE); setCropBoxAndClose(); } else { mCropPageHost.postDelayed(new Runnable() { @Override public void run() { if (mIsActive) { if (mLayoutName.equals("layout-sw480dp-port") || mLayoutName.equals("layout-sw480dp-land")) { if (view.getWidth() < 540) { View buttonHost = view.findViewById(R.id.page_buttons_host); int[] location = new int[2]; buttonHost.getLocationInWindow(location); int buttonsLeft = location[0]; View pageNumText = view.findViewById(R.id.page_num_text_view); pageNumText.getLocationInWindow(location); int pageNumRight = location[0] + pageNumText.getWidth(); if (pageNumRight > buttonsLeft - 10) { RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) buttonHost .getLayoutParams(); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE); layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL, 0); } } } mCropImageBorder.setVisibility(View.VISIBLE); setPage(mCurrentPage); } } }, 200); // Extra delay to ensure that view has time to settle. post alone doesn't work. } getButtons(view); if (mDisablingOverlayShowing) { mDisablingOverlay.setVisibility(View.VISIBLE); } if (mSpinnerShowing) { mProgressBarHost.setVisibility(View.VISIBLE); } }
From source file:im.vector.activity.CallViewActivity.java
/** * Insert the callView in the activity (above the other room member) * @param avatarUrl the other member avatar *//*from w w w .j a v a 2 s .c o m*/ private void insertCallView(String avatarUrl) { ImageView avatarView = (ImageView) CallViewActivity.this.findViewById(R.id.call_other_member); avatarView.setImageResource(R.drawable.ic_contact_picture_holo_light); if (!TextUtils.isEmpty(avatarUrl)) { int size = CallViewActivity.this.getResources().getDimensionPixelSize(R.dimen.member_list_avatar_size); mSession.getMediasCache().loadAvatarThumbnail(mSession.getHomeserverConfig(), avatarView, avatarUrl, size); } RelativeLayout layout = (RelativeLayout) CallViewActivity.this.findViewById(R.id.call_layout); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); layout.addView(mCallView, 1, params); mCall.setVisibility(View.GONE); }
From source file:com.cloud.widget.viewpager.PagerSlidingTabStrip.java
/** * Modify by Cloud on 15/12/1.//from www .j a v a 2 s. c om * TabViewViewGroup */ private void addTextTab(final int position, String title, float num, boolean hasIndicator, boolean hasNum, int tabNum) { relativeLayout = new RelativeLayout(getContext()); if (hasIndicator) { if (hasNum) { //title RelativeLayout.LayoutParams titleLp = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); titleText = new TextView(getContext()); titleText.setText(title); titleText.setGravity(Gravity.CENTER); titleText.setSingleLine(); titleText.setTypeface(tabTypeface, tabTypefaceStyle); titleText.setTextAppearance(getContext(), tabDefaultTextAppearance); titleLp.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); titleText.setLayoutParams(titleLp); // RelativeLayout.LayoutParams indicatorLp = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); indicatorText = new TextView(getContext()); indicatorText.setHeight(px2dip(getContext(), 50)); indicatorText.setWidth(px2dip(getContext(), screenWidth)); indicatorText.setText("" + String.valueOf(num)); indicatorText.setGravity(Gravity.CENTER); indicatorText.setSingleLine(); indicatorLp.topMargin = 5; indicatorLp.bottomMargin = 5; indicatorLp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); indicatorText.setLayoutParams(indicatorLp); relativeLayout.addView(indicatorText); relativeLayout.addView(titleText); } else { //title RelativeLayout.LayoutParams titleLp = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); titleText = new TextView(getContext()); titleText.setText(title); titleText.setGravity(Gravity.CENTER); titleText.setSingleLine(); titleText.setTypeface(tabTypeface, tabTypefaceStyle); titleText.setTextAppearance(getContext(), tabDefaultTextAppearance); titleText.setLayoutParams(titleLp); relativeLayout.addView(titleText); } } else { RelativeLayout.LayoutParams titleLp = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); titleText = new TextView(getContext()); titleText.setGravity(Gravity.CENTER); titleText.setSingleLine(); titleText.setTypeface(tabTypeface, tabTypefaceStyle); titleText.setTextAppearance(getContext(), tabDefaultTextAppearance); titleText.setLayoutParams(titleLp); relativeLayout.addView(titleText); if (num % 1 == 0) { titleText.setText(title + "(" + String.valueOf((int) num) + ")"); } else { titleText.setText(title + "(" + String.valueOf(num) + ")"); } } if (num != 0 && hasIndicator && !hasNum) { // RelativeLayout.LayoutParams indicatorLp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); indicatorText = new TextView(getContext()); indicatorText.setHeight(px2dip(getContext(), 50)); indicatorText.setWidth(px2dip(getContext(), 50)); if (num % 1 == 0) { indicatorText.setText(String.valueOf((int) num)); } else { indicatorText.setText(String.valueOf(num)); } indicatorText.setGravity(Gravity.CENTER); indicatorText.setSingleLine(); indicatorText .setBackgroundDrawable(getContext().getResources().getDrawable(R.drawable.indicator_red_shape)); indicatorText.setTextAppearance(getContext(), indicatorNum); indicatorLp.topMargin = 10; if (tabNum == 4) { indicatorLp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE); } else { indicatorLp.leftMargin = screenWidth / 4 + screenWidth / 16; } indicatorLp.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); indicatorText.setLayoutParams(indicatorLp); relativeLayout.addView(indicatorText); } addTab(position, relativeLayout); }