Java Code Examples for android.widget.RelativeLayout#getChildCount()
The following examples show how to use
android.widget.RelativeLayout#getChildCount() .
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: HWWebView.java From RePlugin-GameSdk with Apache License 2.0 | 6 votes |
/** * 显示自定义错误提示页面 */ protected void showErrorPage() { webParentView = (RelativeLayout) getParent(); initErrorPage(); while (webParentView.getChildCount() > 0) { webParentView.removeView(mMebView); } refreshLinearLayout.setVisibility(View.VISIBLE); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); // lp.addRule(RelativeLayout.CENTER_IN_PARENT); webParentView.addView(refreshLinearLayout, 0, lp); mIsErrorPage = true; }
Example 2
Source File: AppUtils.java From YCWebView with Apache License 2.0 | 6 votes |
/** * view转bitmap */ private static Bitmap viewConversionBitmap(View v) { int w = v.getWidth(); int h = 0; if (v instanceof LinearLayout){ LinearLayout linearLayout = (LinearLayout) v; for (int i = 0; i < linearLayout.getChildCount(); i++) { h += linearLayout.getChildAt(i).getHeight(); } } else if (v instanceof RelativeLayout){ RelativeLayout relativeLayout = (RelativeLayout) v; for (int i = 0; i < relativeLayout.getChildCount(); i++) { h += relativeLayout.getChildAt(i).getHeight(); } } else { h = v.getHeight(); } Bitmap bmp = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(bmp); //如果不设置canvas画布为白色,则生成透明 c.drawColor(Color.WHITE); v.layout(0, 0, w, h); v.draw(c); return bmp; }
Example 3
Source File: ImageViewSensorAnimationBehavior.java From science-journal with Apache License 2.0 | 6 votes |
@Override public void initializeLargeIcon(RelativeLayout layout, @Nullable Double value) { // Remove previous views. if (layout.getChildCount() > 0) { layout.removeAllViews(); } ImageView largeIcon = new ImageView(layout.getContext()); layout.addView( largeIcon, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); largeIcon.setImageDrawable(getLevelDrawable(largeIcon.getContext())); largeIcon.setRotation(0.0f); // Icon level depends on type -- we want to pick something in the middle to look reasonable. if (behaviorType == TYPE_ACCELEROMETER_SCALE || behaviorType == TYPE_ACCELEROMETER_SCALE_ROTATES) { // Pick the middle icon largeIcon.setImageLevel(2); } else if (behaviorType == TYPE_POSITIVE_RELATIVE_SCALE || behaviorType == TYPE_RELATIVE_SCALE) { // Pick the most exciting icon (the biggest value represented) largeIcon.setImageLevel(3); } }
Example 4
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 5
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 6
Source File: DisplayActivity.java From DataLogger with MIT License | 5 votes |
public void refreshContentLayout() { // The toolbar is updated to include a reference to the current location of the device getSupportActionBar().setTitle( getResources().getString(R.string.toolbar_base_title) + " | @" + SharedPreferencesHelper.getDeviceLocation(this) ); // When the location is not the hand, the visibility of several layouts (file upload, // activity selection, data collection switch and label annotation) is GONE int visibility = (mDeviceLocation != Constants.DEVICE_LOCATION_HAND) ? View.GONE : View.VISIBLE; int[] layoutsId = new int[]{R.id.connectivity_ui, R.id.activities_labels_ui, R.id.data_collection_ui, R.id.label_annotation_ui, R.id.label_annotation_timer}; for (int layoutId : layoutsId) { if (layoutId == R.id.data_collection_ui) { Button dataCollectionButton = ((Button) findViewById(R.id.ui_data_collection_button)); if (dataCollectionButton != null) dataCollectionButton.setVisibility(visibility); } else { RelativeLayout layout = (RelativeLayout) findViewById(layoutId); for (int i = 0; i < layout.getChildCount(); i++) { layout.getChildAt(i).setVisibility(visibility); } } } mBluetoothButton = (Button) findViewById(R.id.ui_bluetooth_status_button); if (mDeviceLocation == Constants.DEVICE_LOCATION_HAND) { mBluetoothButton.setVisibility(View.INVISIBLE); if (menu != null) menu.findItem(R.id.action_pair).setVisible(true); } else if (menu != null) menu.findItem(R.id.action_pair).setVisible(false); }
Example 7
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 8
Source File: AppUtils.java From YCWebView with Apache License 2.0 | 5 votes |
/** * 截取RelativeLayout **/ public static Bitmap getRelativeLayoutBitmap(RelativeLayout relativeLayout) { int h = 0; Bitmap bitmap; for (int i = 0; i < relativeLayout.getChildCount(); i++) { h += relativeLayout.getChildAt(i).getHeight(); } // 创建对应大小的bitmap bitmap = Bitmap.createBitmap(relativeLayout.getWidth(), h, Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(bitmap); relativeLayout.draw(canvas); return bitmap; }
Example 9
Source File: X5WebUtils.java From YCWebView with Apache License 2.0 | 5 votes |
/** * view转bitmap,如果是截图控件中有scrollView,那么可以取它的子控件LinearLayout或者RelativeLayout * @param v view * @return bitmap对象 */ private static Bitmap viewConversionBitmap(View v) { int w = v.getWidth(); int h = 0; if (v instanceof LinearLayout){ LinearLayout linearLayout = (LinearLayout) v; for (int i = 0; i < linearLayout.getChildCount(); i++) { h += linearLayout.getChildAt(i).getHeight(); } } else if (v instanceof RelativeLayout){ RelativeLayout relativeLayout = (RelativeLayout) v; for (int i = 0; i < relativeLayout.getChildCount(); i++) { h += relativeLayout.getChildAt(i).getHeight(); } } else if (v instanceof CoordinatorLayout){ CoordinatorLayout coordinatorLayout = (CoordinatorLayout) v; for (int i = 0; i < coordinatorLayout.getChildCount(); i++) { h += coordinatorLayout.getChildAt(i).getHeight(); } } else { h = v.getHeight(); } Bitmap bmp = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(bmp); //如果不设置canvas画布为白色,则生成透明 c.drawColor(Color.WHITE); v.layout(0, 0, w, h); v.draw(c); return bmp; }
Example 10
Source File: PitchSensorAnimationBehavior.java From science-journal with Apache License 2.0 | 5 votes |
@Override public void initializeLargeIcon(RelativeLayout layout, @Nullable Double value) { // Remove previous views. if (layout.getChildCount() > 0) { layout.removeAllViews(); } Context context = layout.getContext(); ImageViewCanvas largeIcon = new ImageViewCanvas(context); layout.addView( largeIcon, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); largeIcon.setImageDrawable( context.getResources().getDrawable(R.drawable.sound_frequency_drawable)); largeIcon.setPitch((value != null) ? value : 0); }
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: 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 13
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 14
Source File: PopupManager.java From AndroidAnimationExercise with Apache License 2.0 | 4 votes |
public static boolean isShown() { RelativeLayout popupContainer = (RelativeLayout) Shared.activity.findViewById(R.id.popup_container); return popupContainer.getChildCount() > 0; }
Example 15
Source File: MainActivity.java From TvWidget with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); BorderView border = new BorderView(this); border.setBackgroundResource(R.drawable.border_highlight); main = (RelativeLayout) findViewById(R.id.main); border.attachTo(main); for (int i = 0; i < main.getChildCount(); i++) { main.getChildAt(i).setOnClickListener(this); } }
Example 16
Source File: PopupManager.java From memory-game with Apache License 2.0 | 4 votes |
public static boolean isShown() { RelativeLayout popupContainer = (RelativeLayout) Shared.activity.findViewById(R.id.popup_container); return popupContainer.getChildCount() > 0; }