Java Code Examples for android.widget.RelativeLayout#getChildAt()
The following examples show how to use
android.widget.RelativeLayout#getChildAt() .
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: DecorateCalendarFragment.java From DecorateCalendarView with Apache License 2.0 | 6 votes |
private void buildCellOfDay(RelativeLayout cellOfDay, int dayCounter, int dayOfWeek, boolean isToday) { if (cellOfDay == null) return; cellOfDay.setOnClickListener(this); cellOfDay.setBackgroundColor(getResources().getColor(R.color.default_background)); TextView dateText = (TextView) cellOfDay.getChildAt(LABEL_DATE_TEXT_INDEX); dateText.setText(String.valueOf(dayCounter)); if (isToday) dateText.setTypeface(null, Typeface.BOLD); else dateText.setTypeface(null, Typeface.NORMAL); if (mHolidayHightlightType != null && mHolidayHightlightType.equals(HOLIDAY_HIGHLIGHT_TYPE_BACKGROUND)) { if (dayOfWeek == Calendar.SUNDAY) cellOfDay.setBackgroundColor(getResources().getColor(R.color.sunday_background)); else if (dayOfWeek == Calendar.SATURDAY) cellOfDay.setBackgroundColor(getResources().getColor(R.color.saturday_background)); } else { if (dayOfWeek == Calendar.SUNDAY) dateText.setTextColor(getResources().getColor(R.color.sunday_text)); else if (dayOfWeek == Calendar.SATURDAY) dateText.setTextColor(getResources().getColor(R.color.saturday_text)); } }
Example 2
Source File: ExpandableListAdapter.java From AssistantBySDK with Apache License 2.0 | 6 votes |
@Override public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { if (convertView == null) { convertView = inflater.inflate(R.layout.example_list_item, null); } RelativeLayout l = (RelativeLayout) ((LinearLayout) convertView).getChildAt(1); ((ImageView) l.getChildAt(0)).setImageResource((Integer) groups[groupPosition][0]); LinearLayout box = (LinearLayout) l.getChildAt(1); TextView title = (TextView) box.getChildAt(0); title.setText(groups[groupPosition][1].toString()); ((TextView) box.getChildAt(1)).setText(groups[groupPosition][2].toString()); if (isExpanded) { title.setTextColor(mContext.getResources().getColorStateList(R.color.base_blue)); ((ImageView) l.getChildAt(2)).setImageResource(R.drawable.more_up); if (groupPosition > 0) ((LinearLayout) convertView).getChildAt(0).setVisibility(View.VISIBLE); } else { title.setTextColor(mContext.getResources().getColorStateList(R.color.new_text_color_first)); ((ImageView) l.getChildAt(2)).setImageResource(R.drawable.more_dowm); ((LinearLayout) convertView).getChildAt(0).setVisibility(View.INVISIBLE); } return convertView; }
Example 3
Source File: RhythmAdapter.java From MousePaint with MIT License | 6 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { RelativeLayout relativeLayout = (RelativeLayout) this.mInflater.inflate(R.layout.adapter_rhythm_icon, null); //set item layout size and y postion relativeLayout.setLayoutParams(new RelativeLayout.LayoutParams((int) itemWidth, mContext.getResources().getDimensionPixelSize(R.dimen.rhythm_item_height))); relativeLayout.setTranslationY(itemWidth); //set second RelativeLayout width and height RelativeLayout childRelativeLayout = (RelativeLayout) relativeLayout.getChildAt(0); int relativeLayoutWidth = (int) itemWidth - 2 * mContext.getResources().getDimensionPixelSize(R.dimen.rhythm_icon_margin); childRelativeLayout.setLayoutParams(new RelativeLayout.LayoutParams(relativeLayoutWidth, mContext.getResources().getDimensionPixelSize(R.dimen.rhythm_item_height) - 2 * mContext.getResources().getDimensionPixelSize(R.dimen.rhythm_icon_margin))); ImageView imageIcon = (ImageView) relativeLayout.findViewById(R.id.image_icon); //cul ImageView size int iconSize = (relativeLayoutWidth - 2 * mContext.getResources().getDimensionPixelSize(R.dimen.rhythm_icon_margin)); ViewGroup.LayoutParams iconParams = imageIcon.getLayoutParams(); iconParams.width = iconSize; iconParams.height = iconSize; imageIcon.setLayoutParams(iconParams); //set bg img Glide.with(mContext).load(mCardList.get(position).getIconUrl()).fitCenter().into(imageIcon); return relativeLayout; }
Example 4
Source File: RhythmAdapter.java From NBAPlus with Apache License 2.0 | 6 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { RelativeLayout relativeLayout = (RelativeLayout) this.mInflater.inflate(R.layout.adapter_rhythm_icon, null); //设置item布局的大小以及Y轴的位置 relativeLayout.setLayoutParams(new RelativeLayout.LayoutParams((int) itemWidth, mContext.getResources().getDimensionPixelSize(R.dimen.rhythm_item_height))); relativeLayout.setTranslationY(itemWidth*3/7); //设置第二层RelativeLayout布局的宽和高 RelativeLayout childRelativeLayout = (RelativeLayout) relativeLayout.getChildAt(0); CardView cardRhythm = (CardView)relativeLayout.findViewById(R.id.card_rhythm); TextView statName=(TextView)relativeLayout.findViewById(R.id.stat_name); cardRhythm.setCardBackgroundColor(mColorList[position]); statName.setText(sStatNames[position]); int relativeLayoutWidth = (int) itemWidth - 2 * mContext.getResources().getDimensionPixelSize(R.dimen.rhythm_icon_margin); childRelativeLayout.setLayoutParams(new RelativeLayout.LayoutParams(relativeLayoutWidth, mContext.getResources().getDimensionPixelSize(R.dimen.rhythm_item_height) - 2 * mContext.getResources().getDimensionPixelSize(R.dimen.rhythm_icon_margin))); return relativeLayout; }
Example 5
Source File: SettingsFragment.java From NMSAlphabetAndroidApp with MIT License | 6 votes |
private void updatePreferences(ListView accountList){ for(int i = 0; i < accountList.getChildCount(); i++) { try { LinearLayout rootLayout = (LinearLayout) accountList.getChildAt(i); RelativeLayout preferenceLayout = (RelativeLayout) rootLayout.getChildAt(1); TextView titleView = (TextView) preferenceLayout.getChildAt(0); TextView summaryView = (TextView) preferenceLayout.getChildAt(1); if(titleView.getText().toString().equals(getString(R.string.language))) { summaryView.setCompoundDrawablePadding(10); summaryView.setCompoundDrawablesRelativeWithIntrinsicBounds(LanguageUtil.getLanguageFlagDrawable(getActivity(), LanguageUtil.getCurrentLanguageCode(getActivity())), null, null, null); } else if(titleView.getText().toString().equals(getString(R.string.theme))) { summaryView.setText(ThemeUtil.getThemePreview(getActivity(), ThemeUtil.getCurrentTheme(getActivity()))); summaryView.setTextSize(30); } } catch (Exception e){ e.printStackTrace(); } } }
Example 6
Source File: BaseBottomDelegate.java From FastWaiMai with MIT License | 5 votes |
@Override public void onBindView(@Nullable Bundle savedInstanceState, @NonNull View view) { final int size = ITEMS.size(); for(int i = 0; i < size; i++){ LayoutInflater.from(getContext()).inflate(R.layout.bottom_item_icon_text_layout, mBottomBar); final RelativeLayout item = (RelativeLayout) mBottomBar.getChildAt(i); //设置每一个item的点击事件 item.setTag(i); item.setOnClickListener(this); //图标 final IconTextView itemIcon = (IconTextView) item.getChildAt(0); //文字 final AppCompatTextView itemTitle = (AppCompatTextView) item.getChildAt(1); final BottomTabBean bean = TAB_BEANS.get(i); //初始化数据 itemIcon.setText(bean.getIcon()); itemTitle.setText(bean.getTitle()); if (i == mIndexDelegate) { itemIcon.setTextColor(mClickedColor); itemTitle.setTextColor(mClickedColor); } } final ISupportFragment[] delegateArray = ITEM_DELEGATES.toArray(new ISupportFragment[size]); //加载多个同级根Fragment,类似Wechat, QQ主页的场景 getSupportDelegate().loadMultipleRootFragment(R.id.bottom_bar_delegate_container, mIndexDelegate, delegateArray); }
Example 7
Source File: CardStack.java From Pimp_my_Z1 with GNU General Public License v2.0 | 5 votes |
/** * Attempt to modify the convertView instead of inflating a new View for this CardStack. * If convertView isn't compatible, it isn't modified. * * @param convertView view to try reusing * @return true on success, false if the convertView is not compatible */ private boolean convert(View convertView) { // only convert singleton stacks if (cards.size() != 1) { Log.d("CardsUI", "Can't convert view: amount of cards is " + cards.size()); return false; } RelativeLayout container = (RelativeLayout) convertView.findViewById(R.id.stackContainer); if (container == null) { Log.d("CardsUI", "Can't convert view: can't find stackContainer"); return false; } if (container.getChildCount() != 1) { Log.d("CardsUI", "Can't convert view: child count is " + container.getChildCount()); return false; } // check to see if they're compatible Card types Card card = cards.get(0); View convertCardView = container.getChildAt(0); if (convertCardView == null || convertCardView.getId() != card.getId()) { Log.d("CardsUI", String.format("Can't convert view: child Id is 0x%x, card Id is 0x%x", convertCardView.getId(), card.getId())); return false; } if (card.convert(convertCardView)) return true; return false; }
Example 8
Source File: PopupManager.java From memory-game with Apache License 2.0 | 5 votes |
public static void closePopup() { final RelativeLayout popupContainer = (RelativeLayout) Shared.activity.findViewById(R.id.popup_container); int childCount = popupContainer.getChildCount(); if (childCount > 0) { View background = null; View viewPopup = null; if (childCount == 1) { viewPopup = popupContainer.getChildAt(0); } else { background = popupContainer.getChildAt(0); viewPopup = popupContainer.getChildAt(1); } AnimatorSet animatorSet = new AnimatorSet(); ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(viewPopup, "scaleX", 0f); ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(viewPopup, "scaleY", 0f); if (childCount > 1) { ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(background, "alpha", 0f); animatorSet.playTogether(scaleXAnimator, scaleYAnimator, alphaAnimator); } else { animatorSet.playTogether(scaleXAnimator, scaleYAnimator); } animatorSet.setDuration(300); animatorSet.setInterpolator(new AccelerateInterpolator(2)); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { popupContainer.removeAllViews(); } }); animatorSet.start(); } }
Example 9
Source File: EditDatabaseActivity.java From AndroidFaceRecognizer with MIT License | 5 votes |
@Override public void onItemClick(AdapterView<?> a, View view, int position, long id) { if(buttonClicked){ return; } buttonClicked = true; final RelativeLayout itemLayout = (RelativeLayout)view; final TextView itemText = (TextView)itemLayout.getChildAt(1); final RelativeLayout overLay = new RelativeLayout(mContext); overLay.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); overLay.setBackgroundColor(0x99888888); itemLayout.addView(overLay); itemText.setTextColor(Color.DKGRAY); Intent intent = new Intent(EditDatabaseActivity.this, FaceDetectionActivity.class); intent.putExtra("Training", false); intent.putExtra("personIndex", position); EditDatabaseActivity.this.startActivity(intent); EditDatabaseActivity.this.finish(); itemLayout.postDelayed(new Runnable() { @Override public void run() { buttonClicked = false; itemLayout.removeView(overLay); itemText.setTextColor(Color.BLACK); } }, 2000); }
Example 10
Source File: XDListView.java From Cornowser with MIT License | 5 votes |
public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder = new ViewHolder(); LayoutInflater inflater = LayoutInflater.from(getContext()); RelativeLayout mainView = (RelativeLayout) inflater.inflate(R.layout.listview_activity_dualrow, null); holder.TextView1 = (TextView) mainView.getChildAt(0); holder.TextView2 = (TextView) mainView.getChildAt(1); holder.TextView1.setText(getItem(position)); holder.TextView2.setText(getItem(allLength / 2 + position)); holder.TextView1.setSingleLine(); holder.TextView1.setEllipsize(TextUtils.TruncateAt.MIDDLE); holder.TextView2.setSingleLine(); holder.TextView2.setEllipsize(TextUtils.TruncateAt.MIDDLE); return mainView; }
Example 11
Source File: PopupManager.java From AndroidAnimationExercise with Apache License 2.0 | 5 votes |
public static void closePopup() { final RelativeLayout popupContainer = (RelativeLayout) Shared.activity.findViewById(R.id.popup_container); int childCount = popupContainer.getChildCount(); if (childCount > 0) { View background = null; View viewPopup = null; if (childCount == 1) { viewPopup = popupContainer.getChildAt(0); } else { background = popupContainer.getChildAt(0); viewPopup = popupContainer.getChildAt(1); } AnimatorSet animatorSet = new AnimatorSet(); ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(viewPopup, "scaleX", 0f); ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(viewPopup, "scaleY", 0f); if (childCount > 1) { ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(background, "alpha", 0f); animatorSet.playTogether(scaleXAnimator, scaleYAnimator, alphaAnimator); } else { animatorSet.playTogether(scaleXAnimator, scaleYAnimator); } animatorSet.setDuration(300); animatorSet.setInterpolator(new AccelerateInterpolator(2)); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { popupContainer.removeAllViews(); } }); animatorSet.start(); } }
Example 12
Source File: WeChatAdapter.java From KJFrameForAndroid with Apache License 2.0 | 5 votes |
/** * 初始化多图文消息的item * * @param data * @param i * @param itemView */ private void initItem(EverydayMessage data, int i, RelativeLayout itemView) { ImageView itemImg = (ImageView) itemView.getChildAt(0); TextView itemText = (TextView) itemView.getChildAt(1); kjb.display(itemImg, data.getImageUrlList().get(i)); itemText.setText(data.getTitleList().get(i)); itemView.setOnClickListener(getItemMessageClickListener(data .getUrlList().get(i))); }
Example 13
Source File: ChannelTabPageIndicator.java From letv with Apache License 2.0 | 5 votes |
public void setCurrentItem(int item) { if (this.mViewPager != null) { if (item != -1 || this.mSelectedTabIndex != item) { this.mSelectedTabIndex = item; int tabCount = this.mTabLayout.getChildCount(); for (int i = 0; i < tabCount; i++) { RelativeLayout childLayout = (RelativeLayout) this.mTabLayout.getChildAt(i); for (int j = 0; j < childLayout.getChildCount(); j++) { boolean isSelected; if (i == item) { isSelected = true; } else { isSelected = false; } View view = childLayout.getChildAt(j); if (view instanceof TabView) { view.setSelected(isSelected); if (isSelected) { animateToTab(item); } } else { view.setSelected(isSelected); } } } this.mViewPager.setCurrentItem(item, false); } } }
Example 14
Source File: TabsPagerTitleStrip.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void updateCounter(int position, int count, boolean allMuted) { RelativeLayout frame = (RelativeLayout) tabsContainer.getChildAt(position); if (frame != null && frame.getChildCount() > 1) { TextView tv = (TextView) frame.getChildAt(1); if (tv != null) { if (count > 0 && !FeaturedSettings.tabSettings.hideTabsCounters) { tv.setVisibility(VISIBLE); tv.setText(count >= 10000 && FeaturedSettings.tabSettings.limitTabsCounters ? "+9999" : String.format(Locale.getDefault(), "%d", count)); tv.getBackground().setColorFilter(allMuted ? Theme.getColor(Theme.key_chats_unreadCounterMuted) : Theme.getColor(Theme.key_chats_unreadCounter), PorterDuff.Mode.SRC_IN); } else { tv.setVisibility(INVISIBLE); } tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13); tv.setTextColor(Theme.getColor(Theme.key_chats_unreadCounterText)); tv.setPadding(AndroidUtilities.dp(FeaturedSettings.tabSettings.chatsTabCounterSize > 10 ? FeaturedSettings.tabSettings.chatsTabCounterSize - 7 : 4), 0, AndroidUtilities.dp(FeaturedSettings.tabSettings.chatsTabCounterSize > 10 ? FeaturedSettings.tabSettings.chatsTabCounterSize - 7 : 4), 0); } } }
Example 15
Source File: BaseBottomDelegate.java From FastWaiMai with MIT License | 5 votes |
private void resetColor(){ final int count = mBottomBar.getChildCount(); for(int i = 0; i < count; i++){ final RelativeLayout item = (RelativeLayout) mBottomBar.getChildAt(i); final IconTextView itemIcon = (IconTextView) item.getChildAt(0); itemIcon.setTextColor(Color.GRAY); final AppCompatTextView itemTitle = (AppCompatTextView) item.getChildAt(1); itemTitle.setTextColor(Color.GRAY); } }
Example 16
Source File: BaseBottomDelegate.java From FastWaiMai with MIT License | 5 votes |
@Override public void onClick(View v) { final int tag = (int) v.getTag(); resetColor(); final RelativeLayout item = (RelativeLayout) v; //切换颜色 final IconTextView itemIcon = (IconTextView) item.getChildAt(0); itemIcon.setTextColor(mClickedColor); final AppCompatTextView itemTitle = (AppCompatTextView) item.getChildAt(1); itemTitle.setTextColor(mClickedColor); //切换Fragment showFragment hideFragment getSupportDelegate().showHideFragment(ITEM_DELEGATES.get(tag), ITEM_DELEGATES.get(mCurrentDelegate)); mCurrentDelegate = tag; }
Example 17
Source File: TabsPagerTitleStrip.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void updateCounter(int position, int count, boolean allMuted) { RelativeLayout frame = (RelativeLayout) tabsContainer.getChildAt(position); if (frame != null && frame.getChildCount() > 1) { TextView tv = (TextView) frame.getChildAt(1); if (tv != null) { if (count > 0 && !FeaturedSettings.tabSettings.hideTabsCounters) { tv.setVisibility(VISIBLE); tv.setText(count >= 10000 && FeaturedSettings.tabSettings.limitTabsCounters ? "+9999" : String.format(Locale.getDefault(), "%d", count)); tv.getBackground().setColorFilter(allMuted ? Theme.getColor(Theme.key_chats_unreadCounterMuted) : Theme.getColor(Theme.key_chats_unreadCounter), PorterDuff.Mode.SRC_IN); } else { tv.setVisibility(INVISIBLE); } tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13); tv.setTextColor(Theme.getColor(Theme.key_chats_unreadCounterText)); tv.setPadding(AndroidUtilities.dp(FeaturedSettings.tabSettings.chatsTabCounterSize > 10 ? FeaturedSettings.tabSettings.chatsTabCounterSize - 7 : 4), 0, AndroidUtilities.dp(FeaturedSettings.tabSettings.chatsTabCounterSize > 10 ? FeaturedSettings.tabSettings.chatsTabCounterSize - 7 : 4), 0); } } }
Example 18
Source File: PitchSensorAnimationBehavior.java From science-journal with Apache License 2.0 | 4 votes |
private ImageViewCanvas getImageViewCanvas(RelativeLayout layout) { return (ImageViewCanvas) layout.getChildAt(0); }
Example 19
Source File: MapTest.java From appinventor-extensions with Apache License 2.0 | 4 votes |
private MapView getMapView() { RelativeLayout layout = (RelativeLayout) map.getView(); return (MapView) layout.getChildAt(0); }
Example 20
Source File: SelectOneAutoAdvanceWidget.java From commcare-android with Apache License 2.0 | 4 votes |
public SelectOneAutoAdvanceWidget(Context context, FormEntryPrompt prompt) { super(context, prompt); LayoutInflater inflater = LayoutInflater.from(getContext()); mItems = getSelectChoices(); buttons = new Vector<>(); listener = (AdvanceToNextListener)context; String s = null; if (prompt.getAnswerValue() != null) { s = ((Selection)prompt.getAnswerValue().getValue()).getValue(); } //Is this safe enough from collisions? buttonIdBase = Math.abs(prompt.getIndex().hashCode()); if (mItems != null) { for (int i = 0; i < mItems.size(); i++) { RelativeLayout thisParentLayout = (RelativeLayout)inflater.inflate(R.layout.quick_select_layout, null); final LinearLayout questionLayout = (LinearLayout)thisParentLayout.getChildAt(0); ImageView rightArrow = (ImageView)thisParentLayout.getChildAt(1); final RadioButton r = new RadioButton(getContext()); r.setOnCheckedChangeListener(this); String markdownText = prompt.getSelectItemMarkdownText(mItems.get(i)); if (markdownText != null) { r.setText(forceMarkdown(markdownText)); } else { r.setText(prompt.getSelectChoiceText(mItems.get(i))); } r.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mQuestionFontSize); r.setId(i + buttonIdBase); r.setEnabled(!prompt.isReadOnly()); r.setFocusable(!prompt.isReadOnly()); Drawable image = getResources().getDrawable(R.drawable.icon_auto_advance_arrow); rightArrow.setImageDrawable(image); rightArrow.setOnTouchListener((v, event) -> { r.onTouchEvent(event); return false; }); buttons.add(r); if (mItems.get(i).getValue().equals(s)) { r.setChecked(true); } String audioURI = null; audioURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), FormEntryCaption.TEXT_FORM_AUDIO); String imageURI = null; imageURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), FormEntryCaption.TEXT_FORM_IMAGE); String videoURI = null; videoURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), "video"); String bigImageURI = null; bigImageURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), "big-image"); MediaLayout mediaLayout = MediaLayout.buildAudioImageVisualLayout(getContext(), r, audioURI, imageURI, videoURI, bigImageURI); questionLayout.addView(mediaLayout); // Last, add the dividing line (except for the last element) ImageView divider = new ImageView(getContext()); divider.setBackgroundResource(android.R.drawable.divider_horizontal_bright); if (i != mItems.size() - 1) { mediaLayout.addDivider(divider); } addView(thisParentLayout); } } }