Example usage for android.widget RelativeLayout findViewById

List of usage examples for android.widget RelativeLayout findViewById

Introduction

In this page you can find the example usage for android.widget RelativeLayout findViewById.

Prototype

@Nullable
public final <T extends View> T findViewById(@IdRes int id) 

Source Link

Document

Finds the first descendant view with the given ID, the view itself if the ID matches #getId() , or null if the ID is invalid (< 0) or there is no matching view in the hierarchy.

Usage

From source file:com.luseen.spacenavigation.BadgeHelper.java

/**
 * Show badge/*  w  w  w .j  ava2  s.  c om*/
 *
 * @param view      target badge
 * @param badgeItem BadgeItem object
 */
static void showBadge(RelativeLayout view, BadgeItem badgeItem) {

    Utils.changeViewVisibilityVisible(view);
    TextView badgeTextView = (TextView) view.findViewById(R.id.badge_text_view);
    badgeTextView.setText(badgeItem.getBadgeText());

    view.setScaleX(0);
    view.setScaleY(0);

    ViewCompat.animate(view).setDuration(200).scaleX(1).scaleY(1).setListener(new SimpleViewAnimatorListener() {
        @Override
        public void onAnimationEnd(View view) {
            Utils.changeViewVisibilityVisible(view);
        }
    }).start();
}

From source file:com.luseen.spacenavigation.BadgeHelper.java

/**
 * Force show badge without animation/*w  w w.  j a v a  2 s  .c  om*/
 *
 * @param view      target budge
 * @param badgeItem BadgeItem object
 */
static void forceShowBadge(RelativeLayout view, BadgeItem badgeItem) {
    Utils.changeViewVisibilityVisible(view);
    view.setBackground(makeShapeDrawable(badgeItem.getBadgeColor()));
    TextView badgeTextView = (TextView) view.findViewById(R.id.badge_text_view);
    badgeTextView.setText(badgeItem.getBadgeText());
}

From source file:com.prasanna.android.stacknetwork.utils.MarkdownFormatter.java

private static RelativeLayout getTextViewForCode(final Context context, final String text) {
    final LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final RelativeLayout codeLayout = (RelativeLayout) inflater.inflate(R.layout.code, null);
    final WebView webView = (WebView) codeLayout.findViewById(R.id.code);
    loadText(webView, text);//from   w  w w.  ja va 2  s.  c  o m

    StackXQuickActionMenu quickActionMenu = new StackXQuickActionMenu(context)
            .addEmailQuickActionItem("Code sample from StackX", text).addCopyToClipboardItem(text);
    final QuickActionMenu actionMenu = quickActionMenu.addItem(R.string.fullscreen, new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(context, FullscreenTextActivity.class);
            intent.putExtra(StringConstants.TEXT, text);
            context.startActivity(intent);
        }
    }).build();

    ImageView imageView = (ImageView) codeLayout.findViewById(R.id.codeQuickActionMenu);
    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            actionMenu.show(v);
        }
    });

    return codeLayout;
}

From source file:fr.shywim.antoinedaniel.utils.Utils.java

/**
 * Second part of the click animation./*from   w w  w .j a  v a2s  .c o  m*/
 *
 * @param v View who will have the effect.
 * @param isRoot Whether the passed view is the ViewGroup parent.
 */
public static void clickAnimUp(View v, boolean isRoot) {
    RelativeLayout root;
    if (isRoot)
        root = (RelativeLayout) v;
    else
        root = (RelativeLayout) v.getParent();
    final View rectView = root.findViewById(R.id.rect_view_id);
    if (rectView != null) {
        AlphaAnimation rectAnim = new AlphaAnimation(0.4f, 0f);
        rectAnim.setFillAfter(true);
        rectAnim.setInterpolator(new DecelerateInterpolator());
        rectAnim.setDuration(150);
        rectAnim.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                new Handler().post(new Runnable() {
                    @Override
                    public void run() {
                        ViewGroup parent = (ViewGroup) rectView.getParent();
                        rectView.setVisibility(View.GONE);
                        if (parent != null)
                            parent.removeView(rectView);
                    }
                });
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
        rectView.clearAnimation();
        rectView.startAnimation(rectAnim);
    }
}

From source file:fm.feed.android.testapp.fragment.SlidingBottomFragment.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    RelativeLayout rootView = (RelativeLayout) inflater.inflate(R.layout.fragment_sliding_bottom, container,
            false);/*from w  w  w  .  j a va2 s  .  c  o m*/

    mOverlay = rootView.findViewById(R.id.overlay);

    rootView.findViewById(R.id.close).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            getActivity().onBackPressed();
        }
    });

    /**
     * Override default PlayerView Shared Subject title
     */
    PlayerView playerView = (PlayerView) rootView.findViewById(R.id.player);
    playerView.setShareSubject("Currently listening from a bottom panel!");

    return rootView;
}

From source file:nl.hnogames.domoticz.Fragments.Camera.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    RelativeLayout group = (RelativeLayout) inflater.inflate(R.layout.camera_default, null);
    if (mSharedPrefs.darkThemeEnabled()) {
        group.findViewById(R.id.row_global_wrapper)
                .setBackgroundColor(getResources().getColor(R.color.background_dark));
    }/*w ww  .j a  va2 s  .  c  o m*/
    root = (ImageView) group.findViewById(R.id.image);
    FloatingActionButton fabButton = (FloatingActionButton) group.findViewById(R.id.fab);
    fabButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            processImage();
        }
    });

    if (this.url.length() > 0)
        setImage(this.url);
    return group;
}

From source file:fm.feed.android.playersdk.fragment.SlidingBottomPlayerFragment.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    RelativeLayout rootView = (RelativeLayout) inflater.inflate(R.layout.feed_fm_sliding_bottom_player_fragment,
            container, false);//from w  w  w  .j  a v  a 2 s.  c om

    mOverlay = rootView.findViewById(R.id.overlay);

    rootView.findViewById(R.id.close).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            getActivity().onBackPressed();
        }
    });

    /**
     * Override default PlayerView Shared Subject title
     */
    PlayerView playerView = (PlayerView) rootView.findViewById(R.id.player);
    playerView.setShareSubject("Currently listening from a bottom panel!");

    return rootView;
}

From source file:org.coursera.android.shift.ShiftIconFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    final RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.shift_menu, container, false);

    mHead = layout.findViewById(R.id.head);
    final RelativeLayout.LayoutParams iconParams;
    iconParams = (RelativeLayout.LayoutParams) mHead.getLayoutParams();

    final GestureDetector gestureDetector = new GestureDetector(getActivity(), new SingleTapConfirm());

    mHead.setOnTouchListener(new View.OnTouchListener() {
        private int initialX;
        private int initialY;
        private float initialTouchX;
        private float initialTouchY;

        @Override//from  ww w .j  a va 2s . com
        public boolean onTouch(View v, MotionEvent event) {
            final int yLimit = layout.getMeasuredHeight() - mHead.getMeasuredHeight();
            final int xLimit = layout.getMeasuredWidth() - mHead.getMeasuredWidth();

            // single tap
            if (gestureDetector.onTouchEvent(event)) {
                mShiftLauncherView.showShiftMenu(getActivity());
                return true;
            }

            // drag icon
            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                initialX = iconParams.leftMargin;
                initialY = iconParams.topMargin;
                initialTouchX = event.getRawX();
                initialTouchY = event.getRawY();
                return true;
            case MotionEvent.ACTION_CANCEL:
                return false;
            case MotionEvent.ACTION_UP:
                return true;
            case MotionEvent.ACTION_MOVE:
                int newX = initialX + (int) (event.getRawX() - initialTouchX);
                int newY = initialY + (int) (event.getRawY() - initialTouchY);

                iconParams.leftMargin = newX < 0 ? 0 : Math.min(newX, xLimit);
                iconParams.topMargin = newY < 0 ? 0 : Math.min(newY, yLimit);

                layout.updateViewLayout(mHead, iconParams);
                return true;
            }
            return false;
        }
    });
    return layout;
}

From source file:org.ambient.control.home.roomitems.ClimateStrategy.java

private void updateIcon(RelativeLayout itemContent, TemperaturMode mode) {
    ImageView icon = (ImageView) itemContent.findViewById(R.id.imageViewHeatingIcon);

    boolean disabled = mode.temp <= MaxUtil.MIN_TEMPERATURE + 0.1f;

    if (mode.thermostateMode == null) {
        icon.setImageResource(R.drawable.ic_heating_active);
    } else if (mode.thermostateMode == MaxThermostateMode.AUTO
            || mode.thermostateMode == MaxThermostateMode.MANUAL
            || mode.thermostateMode == MaxThermostateMode.TEMPORARY) {
        if (disabled) {
            icon.setImageResource(R.drawable.ic_heating_disabled);
        } else {//from  ww w.  j av  a  2 s  .  c o m
            icon.setImageResource(R.drawable.ic_heating_active);
        }
    } else if (mode.thermostateMode == MaxThermostateMode.BOOST) {
        icon.setImageResource(R.drawable.ic_heating_boost);
    }

    TextView modeText = (TextView) itemContent.findViewById(R.id.textViewTempMode);
    if (mode.thermostateMode == null) {
        modeText.setText("");
    } else if (mode.thermostateMode == MaxThermostateMode.AUTO) {
        modeText.setText("A");
    } else if (mode.thermostateMode == MaxThermostateMode.BOOST) {
        modeText.setText("B");
    } else if (mode.thermostateMode == MaxThermostateMode.MANUAL) {
        modeText.setText("M");
    } else if (mode.thermostateMode == MaxThermostateMode.TEMPORARY) {
        modeText.setText("T");
    }

    TextView tempText = (TextView) itemContent.findViewById(R.id.textViewTempDegree);
    if (mode.thermostateMode != MaxThermostateMode.BOOST && mode.temp > MaxUtil.MIN_TEMPERATURE) {
        tempText.setText(String.valueOf(mode.temp));
        tempText.setTextColor(GuiUtils.getColor(3f, GuiUtils.getTemperatureTextColor(climate.temperature,
                climate.comfortTemperatur, MaxUtil.MAX_TEMPERATURE, MaxUtil.MIN_TEMPERATURE)));
    } else {
        tempText.setText("");
    }
}

From source file:net.saga.aeroconf.app.ui.fragment.DashboardFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    RelativeLayout v = (RelativeLayout) inflater.inflate(R.layout.dashboard, container, false);
    assert v != null;

    ListView cardList = (ListView) v.findViewById(R.id.cards_list_view);

    cardList.setAdapter(new ArrayAdapter<DashboardCard>(getActivity(), R.layout.dashboard_card, CARDS) {
        @Override//w  ww .j av a 2  s .co m
        public View getView(int position, View convertView, ViewGroup parent) {
            if (convertView == null) {
                convertView = View.inflate(getContext(), R.layout.dashboard_card, null);
            }

            DashboardCard card = CARDS[position];

            final ImageView img = (ImageView) convertView.findViewById(R.id.dashboard_card_image);
            final TextView text = (TextView) convertView.findViewById(R.id.dashboard_card_description);

            text.setText(card.text);

            CachingImageProvider.getInstance(getContext()).loadImage(Uri.parse(card.imageUrl.toString()),
                    new CachingImageProvider.ImageLoaded() {
                        @Override
                        public void onImageLoad(Bitmap bitmap) {
                            if (!stopped) {
                                img.setImageDrawable(new BitmapDrawable(getResources(), bitmap));
                            }
                        }
                    });

            return convertView;
        }
    });

    return v;
}