Example usage for android.widget RelativeLayout getLayoutParams

List of usage examples for android.widget RelativeLayout getLayoutParams

Introduction

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

Prototype

@ViewDebug.ExportedProperty(deepExport = true, prefix = "layout_")
public ViewGroup.LayoutParams getLayoutParams() 

Source Link

Document

Get the LayoutParams associated with this view.

Usage

From source file:com.openlocationcode.android.main.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_act);//from   w  w w .j  a  v a2s.c om
    MyMapView myMapView = (MyMapView) findViewById(R.id.myMapView);
    mMapView = myMapView.getMapView();
    mMainPresenter = new MainPresenter(this, (SearchView) findViewById(R.id.searchView),
            (DirectionView) findViewById(R.id.directionView), (CodeView) findViewById(R.id.codeView),
            myMapView);

    mMapView.onCreate(savedInstanceState);

    // Adjust the map controls and search box top margins to account for the translucent status
    // bar.
    int statusBarHeight = getStatusBarHeight(this);
    LinearLayout mapControl = (LinearLayout) findViewById(R.id.mapControls);
    FrameLayout.LayoutParams mapParams = (FrameLayout.LayoutParams) mapControl.getLayoutParams();
    mapParams.topMargin = mapParams.topMargin + statusBarHeight;
    mapControl.setLayoutParams(mapParams);

    RelativeLayout searchBox = (RelativeLayout) findViewById(R.id.searchBox);
    FrameLayout.LayoutParams searchParams = (FrameLayout.LayoutParams) searchBox.getLayoutParams();
    searchParams.topMargin = searchParams.topMargin + statusBarHeight;
    searchBox.setLayoutParams(searchParams);

    if (getIntent() != null && Intent.ACTION_VIEW.equals(getIntent().getAction())) {
        handleGeoIntent(getIntent());
    }
}

From source file:com.tapcentive.sdk.actions.TapMessageFragment.java

/**
 * Initialize winning layout./*from w ww  .ja v  a  2s.co m*/
 * 
 * @param view
 *            the view
 * @param y
 *            the y coordinate
 */
private void initializeWinningLayout(View view, int y) {
    // Setup the winning layout to be offscreeen
    RelativeLayout layout = (RelativeLayout) view.findViewById(R.id.winning_layout_portrait);
    layout.setY(y);
    layout.getLayoutParams().height = usableHeight;

    // Populate all elements of the winning layout (bitmap, text...)
    initializeWinningLayoutWithReward(view, getCurrentReward());

    // Configure the callback when the "more rewards" button is pressed
    Button tapMessageButton = (Button) view.findViewById(R.id.tap_message_button_portrait);
    tapMessageButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            callback.onTapcentiveInteractionCompleted(_fragment);
        }
    });
}

From source file:com.tweetlanes.android.core.view.BaseLaneFragment.java

void configureLaneWidth(View resultView) {

    RelativeLayout laneContent = (RelativeLayout) resultView.findViewById(R.id.lane_content);
    if (laneContent != null) {
        RelativeLayout tweetFeedLoaded = (RelativeLayout) resultView.findViewById(R.id.tweet_feed_loaded);
        if (tweetFeedLoaded != null) {
            if (!AppSettings.get().showTabletMargin()) {
                android.view.ViewGroup.LayoutParams parentParams = tweetFeedLoaded.getLayoutParams();
                laneContent.setLayoutParams(
                        new RelativeLayout.LayoutParams(parentParams.width, parentParams.height));
            } else {
                /*/*  w w  w  .  j a  v  a2s  .  c o  m*/
                 * final Resources res = getResources(); float width =
                 * res.getDimension(R.dimen.lane_content_width);
                 * RelativeLayout.LayoutParams params = new
                 * RelativeLayout.LayoutParams((int) width,
                 * RelativeLayout.LayoutParams.FILL_PARENT);
                 * params.addRule(RelativeLayout.CENTER_IN_PARENT, -1);
                 * laneContent.setLayoutParams(params);
                 */
            }
        }
    }
}

From source file:com.shafiq.mytwittle.view.BaseLaneFragment.java

public void configureLaneWidth(View resultView) {

    RelativeLayout laneContent = (RelativeLayout) resultView.findViewById(R.id.lane_content);
    if (laneContent != null) {
        RelativeLayout tweetFeedLoaded = (RelativeLayout) resultView.findViewById(R.id.tweet_feed_loaded);
        if (tweetFeedLoaded != null) {
            if (AppSettings.get().showTabletMargin() == false) {
                android.view.ViewGroup.LayoutParams parentParams = tweetFeedLoaded.getLayoutParams();
                laneContent.setLayoutParams(
                        new RelativeLayout.LayoutParams(parentParams.width, parentParams.height));
            } else {
                /*/*from w w w.  ja v  a 2s .c  o m*/
                 * final Resources res = getResources(); float width =
                 * res.getDimension(R.dimen.lane_content_width);
                 * RelativeLayout.LayoutParams params = new
                 * RelativeLayout.LayoutParams((int) width,
                 * RelativeLayout.LayoutParams.FILL_PARENT);
                 * params.addRule(RelativeLayout.CENTER_IN_PARENT, -1);
                 * laneContent.setLayoutParams(params);
                 */
            }
        }
    }
}

From source file:com.tweetlanes.android.view.BaseLaneFragment.java

public void configureLaneWidth(View resultView) {

    RelativeLayout laneContent = (RelativeLayout) resultView.findViewById(R.id.lane_content);
    if (laneContent != null) {
        RelativeLayout tweetFeedLoaded = (RelativeLayout) resultView.findViewById(R.id.tweet_feed_loaded);
        if (tweetFeedLoaded != null) {
            if (AppSettings.get().showTabletMargin() == false) {
                android.view.ViewGroup.LayoutParams parentParams = tweetFeedLoaded.getLayoutParams();
                laneContent.setLayoutParams(
                        new RelativeLayout.LayoutParams(parentParams.width, parentParams.height));
            } else {
                /*/* w  w w.jav a  2 s.co  m*/
                final Resources res = getResources();
                  float width = res.getDimension(R.dimen.lane_content_width);
                  RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams((int) width, RelativeLayout.LayoutParams.FILL_PARENT);
                  params.addRule(RelativeLayout.CENTER_IN_PARENT, -1);
                  laneContent.setLayoutParams(params);
                  */
            }
        }
    }
}

From source file:com.armtimes.activities.SingleArticlePreviewActivity.java

private void initControllers() {
    layoutMain = (LinearLayout) findViewById(R.id.layoutMain);
    // Initialize Main Banner Area where Banner Image and
    // Banner Title are located.
    RelativeLayout layoutBanner = (RelativeLayout) findViewById(R.id.layoutBanner);
    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    // Set Banner Layout proportion to 1/3 of screen.
    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) layoutBanner.getLayoutParams();
    params.height = metrics.heightPixels / 3;
    layoutBanner.setLayoutParams(params);

    // Initialize Banner Image.
    imageBanner = (ImageView) findViewById(R.id.imageViewBanner);
    imageBanner.setScaleType(ImageView.ScaleType.CENTER);

    // Initialize Title Text View.
    textTitle = (TextView) findViewById(R.id.textViewBannerTitle);

    // Initialize Description Text View
    textDescription = (TextView) findViewById(R.id.textViewDescription);
    textDescription.setTextAppearance(getApplicationContext(),
            DialogSettings.getTextFontSize(getApplicationContext()));
    textDescription.setTextColor(Color.BLACK);
}

From source file:net.globide.coloring_book.MainPanelFragment.java

/**
 * Implements onCreateView()./*from   www  .ja v a2  s . c o  m*/
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);

    // Inflate the view for the search fragment.
    View view = inflater.inflate(R.layout.panel_main, container, false);

    // Get the host activity as an object.
    Activity activity = getActivity();

    // If the host activity exists...
    if (activity != null) {

        // Get the selected category data.
        Bundle extras = this.getArguments();
        mCid = extras.getInt("id");
        mCategory = extras.getString("category");

        /*
         * ImageView.
         */

        // Set the current palette cover.
        final ImageButton ibMainColor = (ImageButton) view.findViewById(R.id.ibMainColor);
        // Generate the resource name based on the current category id.
        int imageResourceId = getResources().getIdentifier("cover_" + mCid, "drawable",
                activity.getPackageName());
        // Create a new drawable object to so we can draw our credits image.
        Drawable image = this.getResources().getDrawable(imageResourceId);

        ibMainColor.setImageDrawable(image);

        ibMainColor.setBackgroundColor(Color.TRANSPARENT);

        ibMainColor.setTag("ibMainColor");
        ibMainColor.setOnClickListener(this);

        /*
         * TextView.
         */

        // Set the category name as the title of this coloring book.
        final TextView tvMainTitle = (TextView) view.findViewById(R.id.tvPanelMain);
        tvMainTitle.setText(mCategory);

        /*
         * This screen needs to be dynamically positioned to fit each screen
         * size fluidly.
         */
        RelativeLayout mRlPanelMain = (RelativeLayout) view.findViewById(R.id.rlPanelMain);

        // Determine the floor section size
        Drawable imageFloor = this.getResources().getDrawable(R.drawable.floor);
        // Store the height locally
        int floorHeight = imageFloor.getIntrinsicHeight();

        // Resize the layout views to be centered in their proper positions
        // based on the sizes calculated.
        ViewGroup.LayoutParams paramsTop = mRlPanelMain.getLayoutParams();
        int resultHeight = floorHeight;
        paramsTop.height = resultHeight;
        mRlPanelMain.setLayoutParams(paramsTop);
    }

    return view;
}

From source file:com.amazon.android.tv.tenfoot.ui.fragments.ContentSearchFragment.java

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

    final View view = super.onCreateView(inflater, container, savedInstanceState);

    if (view != null) {
        // Set background color and drawable.
        view.setBackgroundColor(ContextCompat.getColor(getActivity(), android.R.color.transparent));
        view.setBackground(ContextCompat.getDrawable(getActivity(), R.drawable.search_background));

        final SearchBar searchBar = (SearchBar) view.findViewById(R.id.lb_search_bar);
        if (searchBar != null) {

            // Set the left margin of the search bar.
            ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) searchBar
                    .getLayoutParams();/*from w  w  w .  ja va  2  s.c  om*/

            layoutParams.setMarginStart((int) getResources().getDimension(R.dimen.search_bar_margin_left));

            searchBar.setLayoutParams(layoutParams);

            // Move the search bar items next to the search icon.
            RelativeLayout searchBarItems = (RelativeLayout) searchBar.findViewById(R.id.lb_search_bar_items);

            if (searchBarItems != null) {

                RelativeLayout.LayoutParams searchBarItemsLayoutParams = (RelativeLayout.LayoutParams) searchBarItems
                        .getLayoutParams();

                searchBarItemsLayoutParams.setMarginStart(
                        (int) getResources().getDimension(R.dimen.search_bar_items_margin_left));

                searchBarItems.setLayoutParams(searchBarItemsLayoutParams);

                // Set the search bar items background selector.
                searchBarItems.setBackground(ContextCompat.getDrawable(getActivity(),
                        R.drawable.search_edit_text_bg_color_selector));
            }

            // Set speech orb icon.
            mSpeechOrbView = (SpeechOrbView) searchBar.findViewById(R.id.lb_search_bar_speech_orb);

            if (mSpeechOrbView != null) {
                mSpeechOrbView.setOrbIcon(ContextCompat.getDrawable(getActivity(), R.drawable.search_icon));
            }

            final SearchEditText searchEditText = (SearchEditText) searchBar
                    .findViewById(R.id.lb_search_text_editor);

            if (searchEditText != null) {

                mSearchEditText = searchEditText;

                // Handle keyboard being dismissed to prevent focus going to SearchOrb
                // If user presses back from keyboard, you don't get KeyboardDismissListener
                // so handle that here.
                searchEditText.setOnEditorActionListener((textView, actionId, keyEvent) -> {

                    // Track search if keyboard is closed with IME_ACTION_PREVIOUS or
                    // if IME_ACTION_SEARCH occurs.
                    if (actionId == EditorInfo.IME_ACTION_SEARCH
                            || actionId == EditorInfo.IME_ACTION_PREVIOUS) {

                        if (mQuery != null) {
                            AnalyticsHelper.trackSearchQuery(mQuery);
                        }
                    }

                    if (actionId == EditorInfo.IME_ACTION_PREVIOUS) {

                        // Prevent highlighting SearchOrb
                        mSpeechOrbView.setFocusable(false);
                        mSpeechOrbView.clearFocus();
                        // If there are results allow first result to be selected
                        if (mHasResults) {
                            mSearchEditText.clearFocus();
                        }

                        // Hide keyboard since we are handling the action
                        if (isAdded()) {
                            // Ensure we are added before calling getActivity
                            InputMethodManager inputManager = (InputMethodManager) getActivity()
                                    .getSystemService(Context.INPUT_METHOD_SERVICE);
                            if (inputManager != null) {
                                inputManager.hideSoftInputFromWindow(
                                        getActivity().getCurrentFocus().getWindowToken(),
                                        InputMethodManager.HIDE_NOT_ALWAYS);
                            }
                        } else {
                            Log.e(TAG, "Cannot find activity, can't dismiss keyboard");
                            // Couldn't handle action.
                            // Will expose other focus issues potentially.
                            return false;
                        }
                        // No more processing of this action.
                        return true;
                    }
                    // Someone else needs to handle this action.
                    return false;
                });

                // Override the dismiss listener to get around keyboard issue where dismissing
                // keyboard takes user into first search result's
                // content_details_activity_layout page.
                searchEditText.setOnKeyboardDismissListener(() -> {
                    // If search returns results, focus on the first item in the result list.
                    // If search doesn't have results, this will focus on searchEditText again.
                    mSpeechOrbView.setFocusable(false);
                    mSpeechOrbView.clearFocus();
                    // We don't need to clearFocus on SearchEditText here, the first
                    // result will be selected already.
                });
            }
        }
    }
    return view;
}

From source file:com.cleanwiz.applock.ui.activity.LockMainActivity.java

private void initView() {
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    RelativeLayout menu = (RelativeLayout) findViewById(R.id.menu);
    int width = getResources().getDisplayMetrics().widthPixels - DensityUtil.dip2px(mContext, 56 - 8);
    DrawerLayout.LayoutParams params = (android.support.v4.widget.DrawerLayout.LayoutParams) menu
            .getLayoutParams();//  www. ja  va 2s  . c om
    params.width = width;
    menu.setLayoutParams(params);
    drawerLayout.setDrawerListener(new DrawerLayout.DrawerListener() {
        @Override
        public void onDrawerSlide(View view, float v) {

        }

        @Override
        public void onDrawerOpened(View view) {
            closePopView();
            updateLockStatus();
        }

        @Override
        public void onDrawerClosed(View view) {

        }

        @Override
        public void onDrawerStateChanged(int i) {

        }
    });

    tv_lock_status = (TextView) findViewById(R.id.tv_lock_status);
    drawer_logo = (ImageView) findViewById(R.id.drawer_logo);

    actionView = (ActionView) findViewById(R.id.btn_more);
    tv_tab_box = (TextView) findViewById(R.id.tab_box);
    tv_tab_lock = (TextView) findViewById(R.id.tab_lock);

    // tab_thumb
    tab_thumb = findViewById(R.id.tab_thumb);
    RelativeLayout.LayoutParams thumbLp = (RelativeLayout.LayoutParams) tab_thumb.getLayoutParams();
    thumbLp.width = 0;
    tab_thumb.requestLayout();

    // vp_main
    vp_main = (ViewPager) findViewById(R.id.vp_main);
    mainAdapter = new MainPagerAdapter(mContext);
    vp_main.setAdapter(mainAdapter);
    vp_main.setOnPageChangeListener(new PagerListener());

    // pop
    popView = findViewById(R.id.layout_pop);
    pop_background = findViewById(R.id.pop_background);
    pop_background.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            closePopView();
        }
    });
    pop_background.setVisibility(View.INVISIBLE);

    // image info
    btn_menu = (ImageView) findViewById(R.id.btn_menu);

    // txt
    txt_drawer_version_num = (TextView) findViewById(R.id.txt_drawer_version_num);
    txt_drawer_info_reply = (TextView) findViewById(R.id.txt_drawer_info_reply);
}

From source file:org.mozilla.gecko.AboutHomeContent.java

private void updateSyncLayout(boolean isFirstRun, boolean hasTopSites) {
    RelativeLayout syncContainer = (RelativeLayout) findViewById(R.id.sync_box_container);
    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) syncContainer.getLayoutParams();

    int below = R.id.all_top_sites_text;
    if (isFirstRun && !hasTopSites)
        below = R.id.top_sites_top;/*w  ww . ja  v  a2s .  com*/
    else if (!hasTopSites)
        below = R.id.no_top_sites_text;

    int background = R.drawable.abouthome_bg_repeat;
    if (isFirstRun && !hasTopSites)
        background = 0;

    params.addRule(RelativeLayout.BELOW, below);
    syncContainer.setLayoutParams(params);

    syncContainer.setBackgroundResource(background);
}