Example usage for android.widget RelativeLayout addView

List of usage examples for android.widget RelativeLayout addView

Introduction

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

Prototype

public void addView(View child, int index) 

Source Link

Document

Adds a child view.

Usage

From source file:me.piebridge.prevent.ui.UserGuideActivity.java

private void showDonateDialog() {
    RelativeLayout layout = new RelativeLayout(this);
    int pixel = getPixel(0x30);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(pixel, pixel);
    params.addRule(RelativeLayout.CENTER_IN_PARENT);
    layout.addView(new ProgressBar(this), params);
    donateDialog = ProgressDialog.show(this, null, null);
    donateDialog.setContentView(layout);
    donateDialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, pixel * 0x4);
}

From source file:io.github.yavski.fabspeeddial.FabSpeedDial.java

@Override
protected void onAttachedToWindow() {
    super.onAttachedToWindow();

    LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    int coordinatorLayoutOffset = getResources().getDimensionPixelSize(R.dimen.coordinator_layout_offset);
    if (fabGravity == BOTTOM_END || fabGravity == TOP_END) {
        layoutParams.setMargins(0, 0, coordinatorLayoutOffset, 0);
    } else {/*  w w  w.j  av a 2s  .c o m*/
        layoutParams.setMargins(coordinatorLayoutOffset, 0, 0, 0);
    }
    menuItemsLayout.setLayoutParams(layoutParams);

    // Set up the client's FAB
    fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setImageDrawable(fabDrawable);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        fab.setImageTintList(fabDrawableTint);
    }
    if (fabBackgroundTint != null) {
        fab.setBackgroundTintList(fabBackgroundTint);
    }

    fab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (isAnimating)
                return;

            if (isMenuOpen()) {
                closeMenu();
            } else {
                openMenu();
            }
        }
    });

    // Needed in order to intercept key events
    setFocusableInTouchMode(true);

    if (useTouchGuard) {
        ViewParent parent = getParent();

        touchGuard = new View(getContext());
        touchGuard.setOnClickListener(this);
        touchGuard.setWillNotDraw(true);
        touchGuard.setVisibility(GONE);

        if (touchGuardDrawable != null) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                touchGuard.setBackground(touchGuardDrawable);
            } else {
                //noinspection deprecation
                touchGuard.setBackgroundDrawable(touchGuardDrawable);
            }
        }

        if (parent instanceof FrameLayout) {
            FrameLayout frameLayout = (FrameLayout) parent;
            frameLayout.addView(touchGuard);
            bringToFront();
        } else if (parent instanceof CoordinatorLayout) {
            CoordinatorLayout coordinatorLayout = (CoordinatorLayout) parent;
            coordinatorLayout.addView(touchGuard);
            bringToFront();
        } else if (parent instanceof RelativeLayout) {
            RelativeLayout relativeLayout = (RelativeLayout) parent;
            relativeLayout.addView(touchGuard, new RelativeLayout.LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
            bringToFront();
        } else {
            Log.d(TAG,
                    "touchGuard requires that the parent of this FabSpeedDialer be a FrameLayout or RelativeLayout");
        }
    }

    setOnClickListener(this);

    if (shouldOpenMenu)
        openMenu();
}

From source file:com.smartcodeunited.demo.bluetooth.activity.BaseActivity.java

private void initTitleCenterLayout(LayoutInflater inflater) {
    RelativeLayout vg = (RelativeLayout) titleLayout;
    int titleCenter = getTitleCenterLayoutId();
    if (titleCenter > 0) {
        titleCenterView = inflater.inflate(titleCenter, rootLayout, false);
        LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        params.addRule(RelativeLayout.CENTER_IN_PARENT);
        vg.addView(titleCenterView, params);
    }//from w ww  .j a  va  2 s.  co m
}

From source file:com.lurencun.cfuture09.androidkit.uilibs.IntroActivity.java

/**
 * /*from   www.  j  av a  2s  .c  o  m*/
 */
private void createContentView() {
    // ?
    mIntroResource = new IntroResource();
    setIntroViews(mIntroResource);

    // 
    RelativeLayout rootView = new RelativeLayout(this);
    rootView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

    // 
    mViewPager = new ViewPager(this);
    RelativeLayout.LayoutParams pagerParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
    rootView.addView(mViewPager, pagerParams);

    // 
    LinearLayout indicatorLayout = new LinearLayout(this);
    RelativeLayout.LayoutParams indicatorParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    indicatorParams.bottomMargin = mIntroResource.indicatorMarginBottom;
    indicatorParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    indicatorParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    indicatorLayout.setLayoutParams(indicatorParams);
    indicatorLayout.setOrientation(LinearLayout.HORIZONTAL);

    // 
    int indicatorCount = mIntroResource.views.size();
    int padding = mIntroResource.indicatorImagePadding;
    mIndicator = new ArrayList<ImageView>();
    for (int i = 0; i < indicatorCount; i++) {
        ImageView imageView = new ImageView(this);
        LinearLayout.LayoutParams imageParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        imageView.setPadding(padding, padding, padding, padding);
        imageView.setClickable(true);
        imageView.setOnClickListener(this);
        imageView.setImageResource(mIntroResource.indicatorNoSelectedId);
        imageView.setTag(i);
        mIndicator.add(imageView);
        indicatorLayout.addView(imageView, imageParams);
    }

    rootView.addView(indicatorLayout);

    setContentView(rootView);
}

From source file:com.githang.androidkit.app.IntroActivity.java

/**
 * //  w  w  w  .  j  a  va  2  s .co m
 */
private void createContentView() {
    // ?
    mIntroResource = new IntroResource();
    setIntroViews(mIntroResource);

    // 
    RelativeLayout rootView = new RelativeLayout(this);
    rootView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    // 
    mViewPager = new ViewPager(this);
    RelativeLayout.LayoutParams pagerParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    rootView.addView(mViewPager, pagerParams);

    // 
    LinearLayout indicatorLayout = new LinearLayout(this);
    RelativeLayout.LayoutParams indicatorParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    indicatorParams.bottomMargin = mIntroResource.indicatorMarginBottom;
    indicatorParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    indicatorParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    indicatorLayout.setLayoutParams(indicatorParams);
    indicatorLayout.setOrientation(LinearLayout.HORIZONTAL);

    // 
    int indicatorCount = mIntroResource.views.size();
    int padding = mIntroResource.indicatorImagePadding;
    mIndicator = new ArrayList<ImageView>();
    for (int i = 0; i < indicatorCount; i++) {
        ImageView imageView = new ImageView(this);
        LinearLayout.LayoutParams imageParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        imageView.setPadding(padding, padding, padding, padding);
        imageView.setClickable(true);
        imageView.setOnClickListener(this);
        imageView.setImageResource(mIntroResource.indicatorNoSelectedId);
        imageView.setTag(i);
        mIndicator.add(imageView);
        indicatorLayout.addView(imageView, imageParams);
    }

    rootView.addView(indicatorLayout);

    setContentView(rootView);
}

From source file:com.adwhirl.AdWhirlLayout.java

public void pushSubView(ViewGroup subView) {
    RelativeLayout superView = superViewReference.get();
    if (superView == null) {
        return;/*  w  w  w .  j  av a  2s  .  co m*/
    }
    superView.removeAllViews();

    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
            android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    superView.addView(subView, layoutParams);

    Log.d(AdWhirlUtil.ADWHIRL, "Added subview");

    this.activeRation = nextRation;
    countImpression();
}

From source file:com.cricketkorner.cricket.VitamioListActivity.java

/**
 * Part of the activity's life cycle, StartAppAd should be integrated here
 * for the back button exit ad integration.
 *///from w  w w .  j av  a  2  s . c  om
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    myData = new ArrayList<Map<String, Object>>();
    StartAppSDK.init(this, "106556515", "206801872");
    startAppAd = new StartAppAd(this);
    // relativeLayout  =    (RelativeLayout)findViewById(R.id.channelLayout); 

    /** Create Splash Ad **/
    StartAppAd.showSplash(this, savedInstanceState, new SplashConfig().setTheme(Theme.OCEAN)
            .setLogo(R.drawable.ic_launcher).setAppName("Cricket Korner!"));
    setContentView(R.layout.channel_list);
    StartAppAd.showSlider(this);

    title = new ArrayList<String>();
    desc = new ArrayList<String>();
    thumb = new ArrayList<Integer>();

    RelativeLayout mainLayout = (RelativeLayout) findViewById(R.id.channelLayout);

    // Create new StartApp banner
    Banner startAppBanner = new Banner(this);
    RelativeLayout.LayoutParams bannerParameters = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    bannerParameters.addRule(RelativeLayout.CENTER_HORIZONTAL);
    bannerParameters.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);

    // Add the banner to the main layout
    mainLayout.addView(startAppBanner, bannerParameters);

    if (!LibsChecker.checkVitamioLibs(this))
        return;

    if (isNetworkAvailable()) {

        new ServerHitLinks().execute("http://ahmadshahwaiz.com/LiveStreaming/getLinks.php");
    } else {
        Toast.makeText(getApplicationContext(), "Please Connect With Internet", Toast.LENGTH_LONG).show();
        finish();
        finish();
    }
}

From source file:com.antew.redditinpictures.ui.RedditImageListFragmentFree.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    RelativeLayout v = (RelativeLayout) super.onCreateView(inflater, container, savedInstanceState);

    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mHideAds,
            new IntentFilter(ConstsFree.REMOVE_ADS));
    /**//ww  w . ja v  a  2s .  c  o  m
     * If ads are disabled we don't need to load any
     */
    if (!SharedPreferencesHelperFree.getDisableAds(getActivity())) {
        mAdView = new AdView(getActivity(), AdSize.SMART_BANNER, ConstsFree.ADMOB_ID);

        /**
         * The AdView should be attached to the bottom of the screen, with the GridView position above it
         */
        RelativeLayout.LayoutParams adParams = new RelativeLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        adParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
        v.addView(mAdView, adParams);

        mAdView.loadAd(AdUtil.getAdRequest());
    }

    return v;
}

From source file:com.sociablue.nanodegree_p1.MovieListFragment.java

private void startFragmentExitTransition(int width, int height, int x, int y, Movie movie) {

    RelativeLayout rl = (RelativeLayout) getView().findViewById(R.id.movie_list_container);
    PosterImageView posterImageView = new PosterImageView(getActivity());
    View transitionOverlay = new View(getActivity());
    //        RelativeLayout.LayoutParams overlayParams =
    //              new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    RelativeLayout.LayoutParams overlayParams = new RelativeLayout.LayoutParams(Utils.screenWidth(),
            Utils.screenHeight());/*  w w w .jav a 2 s .c  o  m*/
    transitionOverlay.setBackgroundColor(Color.BLACK);
    rl.addView(transitionOverlay, overlayParams);
    Utils.circularReveal(transitionOverlay, x + width / 2, y + height / 2);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(width, height);
    params.leftMargin = x;
    params.topMargin = y;

    posterImageView.setImageResource(MdbConstants.IMAGE_BASE_URL + "w500" + movie.getPosterPath());

    rl.addView(posterImageView, params);
}

From source file:loon.LGame.java

public void addView(final View view, int w, int h, Location location) {
    if (view == null) {
        return;/* www.  j a va 2  s.c  o  m*/
    }
    android.widget.RelativeLayout viewLayout = new android.widget.RelativeLayout(LGame.this);
    android.widget.RelativeLayout.LayoutParams relativeParams = LSystem.createRelativeLayout(location, w, h);
    viewLayout.addView(view, relativeParams);
    addView(viewLayout);
}