Example usage for android.widget RelativeLayout ALIGN_PARENT_TOP

List of usage examples for android.widget RelativeLayout ALIGN_PARENT_TOP

Introduction

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

Prototype

int ALIGN_PARENT_TOP

To view the source code for android.widget RelativeLayout ALIGN_PARENT_TOP.

Click Source Link

Document

Rule that aligns the child's top edge with its RelativeLayout parent's top edge.

Usage

From source file:io.imoji.sdk.grid.ui.ResultView.java

public void loadCategory(String title) {
    int width = getDimension(5);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(width, width);
    int margin = getDimension(6);
    params.setMargins(0, margin, 0, 0);/*from   ww w.j  a  v  a 2 s  .  c  o m*/
    params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    params.addRule(RelativeLayout.CENTER_HORIZONTAL);
    imageView.setLayoutParams(params);

    textView.setText(title);
    textView.setVisibility(VISIBLE);

    startResultAnimation();
}

From source file:com.stemsc.bt.BarcodeCaptureActivity.java

/**
 * Initializes the UI and creates the detector pipeline.
 *///  w w  w  .  j  a v a2  s  .  c o m
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    //   
    //        requestWindowFeature(Window.FEATURE_NO_TITLE);
    // ?? ?
    //        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
    //                WindowManager.LayoutParams.FLAG_FULLSCREEN);

    View view = this.getWindow().getDecorView();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
    }

    setContentView(R.layout.barcode_capture);
    mPreview = (CameraSourcePreview) findViewById(R.id.preview);
    mGraphicOverlay = (GraphicOverlay<BarcodeGraphic>) findViewById(R.id.graphicOverlay);

    // read parameters from the intent used to launch the activity.
    //        boolean autoFocus = getIntent().getBooleanExtra(AutoFocus, false);
    //        boolean useFlash = getIntent().getBooleanExtra(UseFlash, false);
    //    ?
    sPref = PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext());
    autoFocus = sPref.getBoolean("af", true);
    useFlash = sPref.getBoolean("fl", false);
    mRaw = sPref.getBoolean("raw", false);
    mPV = sPref.getBoolean("pv", false);
    mS = sPref.getInt("s", 50);
    mH = sPref.getInt("h", 360);
    mW = sPref.getInt("v", 640);
    //        Log.d(TAG,"=== mS === "+mS);
    //        Log.d(TAG,"=== mH === "+mH);
    //        Log.d(TAG,"=== mW === "+mW);

    // Check for the camera permission before accessing the camera.  If the
    // permission is not granted yet, request permission.
    int rc = ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA);
    if (rc == PackageManager.PERMISSION_GRANTED) {
        createCameraSource(autoFocus, useFlash);
    } else {
        requestCameraPermission();
    }

    //        gestureDetector = new GestureDetector(this, new CaptureGestureListener());
    //        scaleGestureDetector = new ScaleGestureDetector(this, new ScaleListener());

    //        Snackbar.make(mGraphicOverlay, "Tap to capture. Pinch/Stretch to zoom",
    //                Snackbar.LENGTH_LONG)
    //                .show();

    tvSost = (TextView) findViewById(R.id.tvSost);
    lLay = (RelativeLayout) findViewById(R.id.lLayout1);

    if (mPV) {
        mPreview.setVisibility(View.VISIBLE);
    } else {
        mPreview.setVisibility(View.INVISIBLE);
    }

    sbS = (SeekBar) findViewById(R.id.seekBarS);
    sbW = (SeekBar) findViewById(R.id.seekBarW);
    sbH = (SeekBar) findViewById(R.id.seekBarH);

    sbS.setOnSeekBarChangeListener(this);
    sbW.setOnSeekBarChangeListener(this);
    sbH.setOnSeekBarChangeListener(this);

    target = (TextView) findViewById(R.id.target);
    RelativeLayout.LayoutParams MyParams = new RelativeLayout.LayoutParams(64 * mS / 10, 72 * mS / 10);
    MyParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    MyParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    MyParams.topMargin = mW;
    MyParams.leftMargin = mH;
    target.setLayoutParams(MyParams);

    sbS.setProgress(mS);
    sbW.setProgress(mW);
    sbH.setProgress(mH);
    ((TextView) findViewById(R.id.taPar)).setText("" + mS + " " + mW + " " + mH);

    // create instance
    _displayControl = new DisplayControl(this);
    // get current display condition
    _mode = _displayControl.getMode();
    //        _backlight = _displayControl.getBacklight();

    if (_mode == DisplayControl.DISPLAY_MODE_2D) {
        _mode = DisplayControl.DISPLAY_MODE_3D;
        _displayControl.setMode(_mode, true);
    }

    if (mRaw) {
        tvSost.setText("?(raw) ");
        lLay.setVisibility(View.INVISIBLE);

        return; // !!!!!!!!!  !!!!!!!

    }

    lLay2 = (RelativeLayout) findViewById(R.id.lLayout2);

    tvNeed = (TextView) findViewById(R.id.tvNeed);
    tvNeedT = (TextView) findViewById(R.id.tvNeedT);
    tvNeedAT = (TextView) findViewById(R.id.tvNeedAT);
    tvNeedA = (TextView) findViewById(R.id.tvNeedA);
    tvNeedBT = (TextView) findViewById(R.id.tvNeedBT);
    tvNeedB = (TextView) findViewById(R.id.tvNeedB);
    tvNeedQT = (TextView) findViewById(R.id.tvNeedQT);
    tvNeedQ = (TextView) findViewById(R.id.tvNeedQ);

    tvCellT = (TextView) findViewById(R.id.tvCellT);
    tvCell = (TextView) findViewById(R.id.tvCell);
    tvTrayT = (TextView) findViewById(R.id.tvTrayT);
    tvTray = (TextView) findViewById(R.id.tvTray);
    pb1 = (ProgressBar) findViewById(R.id.pb1);

    tvNeedAT.setVisibility(View.INVISIBLE);
    tvNeedA.setVisibility(View.INVISIBLE);
    tvNeedBT.setVisibility(View.INVISIBLE);
    tvNeedB.setVisibility(View.INVISIBLE);
    tvNeedQT.setVisibility(View.INVISIBLE);
    tvNeedQ.setVisibility(View.INVISIBLE);

    tvCellT.setVisibility(View.INVISIBLE);
    tvCell.setVisibility(View.INVISIBLE);
    tvTrayT.setVisibility(View.INVISIBLE);
    tvTray.setVisibility(View.INVISIBLE);

    //  json
    //        AsyncTask<Void, Void, String> tmp = new ParseTask("http://onbqth.com/route2.json");
    //        AsyncTask<Void, Void, String> dStr = tmp.execute();
    new ParseTask("http://onbqth.com/order.json").execute();
}

From source file:org.odk.collect.android.widgets.QuestionWidget.java

protected void addQuestionMediaLayout(View v) {
    if (v == null) {
        Timber.e("cannot add a null view as questionMediaLayout");
        return;//from   www  . j  a v  a  2  s  . c o m
    }
    // default for questionmedialayout
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    params.setMargins(10, 0, 10, 0);
    addView(v, params);
}

From source file:org.loon.framework.android.game.LGameAndroid2DActivity.java

public void initialization(final boolean landscape, final boolean openAD, final Location lad,
        final String publisherId, final String keywords, final int requestInterval) {
    if (openAD) {
        // setVolumeControlStream(AudioManager.STREAM_MUSIC);
        AdManager.setPublisherId(publisherId);
        AdManager.setTestDevices(new String[] { "" });
        AdManager.setAllowUseOfLocation(true);
        view = new LGameAndroid2DView(LGameAndroid2DActivity.this, landscape);
        IHandler handler = view.getGameHandler();
        RelativeLayout mainLayout = new RelativeLayout(LGameAndroid2DActivity.this);
        RelativeLayout.LayoutParams mainParams = new RelativeLayout.LayoutParams(handler.getWidth(),
                handler.getHeight());/*from   w  w w  .  j av  a 2s .c o  m*/
        if (landscape) {
            mainParams.addRule(RelativeLayout.CENTER_HORIZONTAL, 1);
        } else {
            mainParams.addRule(RelativeLayout.CENTER_IN_PARENT, 1);
        }
        mainLayout.addView(view, mainParams);

        adview = new AdView(LGameAndroid2DActivity.this);
        if (keywords != null) {
            adview.setKeywords(keywords);
        }
        adview.setRequestInterval(requestInterval);
        adview.setGravity(Gravity.NO_GRAVITY);
        RelativeLayout rl = new RelativeLayout(LGameAndroid2DActivity.this);
        RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
                LayoutParams.WRAP_CONTENT);
        if (lad == Location.LEFT) {
            lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 1);
        } else if (lad == Location.RIGHT) {
            lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 1);
        } else if (lad == Location.TOP) {
            lp.addRule(RelativeLayout.ALIGN_PARENT_TOP, 1);
        } else {
            lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 1);
        }
        // adview.setVisibility(View.GONE);

        visible = true;
        frameLayout.addView(mainLayout);
        rl.addView(adview, lp);
        frameLayout.addView(rl);
    } else {
        view = new LGameAndroid2DView(LGameAndroid2DActivity.this, landscape);
        IHandler handler = view.getGameHandler();
        RelativeLayout mainLayout = new RelativeLayout(LGameAndroid2DActivity.this);
        RelativeLayout.LayoutParams mainParams = new RelativeLayout.LayoutParams(handler.getWidth(),
                handler.getHeight());
        if (landscape) {
            mainParams.addRule(RelativeLayout.CENTER_HORIZONTAL, 1);
        } else {
            mainParams.addRule(RelativeLayout.CENTER_IN_PARENT, 1);
        }
        mainLayout.addView(view, mainParams);
        frameLayout.addView(mainLayout);
    }
    if (setupSensors) {
        // ??
        this.initSensors();
    }
    if (view != null) {
        gameHandler = view.getGameHandler();
    }
}

From source file:com.spoiledmilk.ibikecph.map.MapActivity.java

@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Util.init(getWindowManager());
    LOG.d("Map activity onCreate");
    this.maxSlide = (int) (4 * Util.getScreenWidth() / 5);
    this.setContentView(R.layout.main_map_activity);
    mapFragment = new SMMapFragment();
    FragmentManager fm = this.getSupportFragmentManager();
    fm.beginTransaction().add(R.id.map_container, mapFragment).commit();
    mapContainer = (FrameLayout) findViewById(R.id.map_container);
    progressBar = (ProgressBar) findViewById(R.id.progressBar);
    leftContainer = (RelativeLayout) findViewById(R.id.leftContainer);
    pinInfoLayout = (RelativeLayout) findViewById(R.id.pinInfoLayout);
    pinInfoLine1 = (TextView) pinInfoLayout.findViewById(R.id.pinAddressLine1);
    pinInfoLine1.setTypeface(IbikeApplication.getBoldFont());
    btnStart = (Button) findViewById(R.id.btnStart);
    btnStart.setOnClickListener(new OnClickListener() {
        @Override/*w  w w.j  a  v  a 2  s.c o m*/
        public void onClick(View v) {
            pinInfoLayout.setClickable(false);
            LOG.d("find route");
            Location start = SMLocationManager.getInstance().getLastValidLocation();
            if (start == null) {
                showRouteNotFoundDlg();
            } else {
                progressBar.setVisibility(View.VISIBLE);
                new SMHttpRequest().getRoute(start, mapFragment.getPinLocation(), null, MapActivity.this);
            }
        }
    });
    btnSaveFavorite = (ImageButton) findViewById(R.id.btnSaveFavorite);
    btnSaveFavorite.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            DB db = new DB(MapActivity.this);
            try {
                if (IbikeApplication.isUserLogedIn()) {
                    if (isSaveFaveoriteEnabled) {
                        favoritesData = new FavoritesData(address.street + " " + address.houseNumber,
                                address.street + " " + address.houseNumber, "favorite",
                                currentLocation.getLatitude(), currentLocation.getLongitude(), -1);
                        db.saveFavorite(favoritesData, MapActivity.this, true);
                        String st = favoritesData.getName() + " - (" + favoritesData.getLatitude() + ","
                                + favoritesData.getLongitude() + ")";
                        IbikeApplication.getTracker().sendEvent("Favorites", "Save", st, (long) 0);
                        leftMenu.reloadFavorites();
                        btnSaveFavorite.setImageResource(R.drawable.drop_pin_add_fav_btn_active);
                    } else if (favoritesData != null) {
                        db.deleteFavorite(favoritesData, MapActivity.this);
                        leftMenu.reloadFavorites();
                        btnSaveFavorite.setImageResource(R.drawable.drop_pin_selector);
                    }

                    isSaveFaveoriteEnabled = !isSaveFaveoriteEnabled;
                } else {
                    launchLoginDialog();
                }
            } catch (Exception e) {

            }
        }

    });
    btnTrack = (ImageButton) findViewById(R.id.btnTrack);
    btnTrack.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!mapFragment.getTrackingMode()) {
                startTrackingUser();
            }
        }
    });
    LOG.d("Map activity btnTrack = " + btnTrack);

    rootLayout = (RelativeLayout) findViewById(R.id.rootLayout);
    FrameLayout.LayoutParams rootParams = new FrameLayout.LayoutParams((int) (9 * Util.getScreenWidth() / 5),
            FrameLayout.LayoutParams.MATCH_PARENT);
    rootLayout.setLayoutParams(rootParams);
    parentContainer = (RelativeLayout) findViewById(R.id.parent_container);
    imgSwiper = (ImageView) findViewById(R.id.imgSwiper);
    imgSwiper.setOnTouchListener(new OnTouchListener() {
        // Swipe the view horizontally
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return onImgSwiperTouch(v, event);
        }

    });
    mapDisabledView = findViewById(R.id.mapDisabledView);
    mapDisabledView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // used to disable the map touching when sliden
            return onImgSwiperTouch(v, event); // true
        }

    });
    btnSearch = (ImageButton) findViewById(R.id.btnSearch);
    btnSearch.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            Intent i = new Intent(MapActivity.this, getSearchActivity());
            startActivityForResult(i, 2);
            overridePendingTransition(R.anim.slide_in_down, R.anim.fixed);
        }

    });
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams((int) Util.getScreenWidth() * 4 / 5,
            RelativeLayout.LayoutParams.MATCH_PARENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    findViewById(R.id.leftContainer).setLayoutParams(params);
    params = new RelativeLayout.LayoutParams((int) Util.getScreenWidth(),
            RelativeLayout.LayoutParams.MATCH_PARENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    findViewById(R.id.parent_container).setLayoutParams(params);
    params = new RelativeLayout.LayoutParams((int) Util.getScreenWidth(),
            RelativeLayout.LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    findViewById(R.id.pinInfoLayout).setLayoutParams(params);
    leftMenu = getLeftMenu();
    FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
    if (savedInstanceState == null) {
        fragmentTransaction.add(R.id.leftContainer, leftMenu);
    } else {
        fragmentTransaction.replace(R.id.leftContainer, leftMenu);
    }
    fragmentTransaction.commit();
    findViewById(R.id.rootLayout).invalidate();

    if (Config.HOCKEY_UPDATES_ENABLED) {
        UpdateManager.register(this, Config.HOCKEY_APP_ID);
    }
}

From source file:de.qspool.clementineremote.ui.fragments.PlayerFragment.java

public void showShowcase() {
    final ShowcaseView sv = new ShowcaseView.Builder(getActivity()).setStyle(R.style.ShowcaseTheme)
            .setTarget(new ActionViewTarget(getActivity(), ActionViewTarget.Type.HOME))
            .setContentTitle(R.string.cm_player_home_title).setContentText(R.string.cm_player_home_content)
            .build();/*from  w  ww . ja  v  a 2s  .  c o m*/
    sv.setButtonText(getString(R.string.cm_next));

    sv.overrideButtonClick(new OnClickListener() {
        @Override
        public void onClick(View v) {
            switch (mShowcaseCounter) {
            case 0:
                sv.setShowcase(new ViewTarget(myPager), true);
                sv.setContentTitle(getString(R.string.cm_player_swipe_title));
                sv.setContentText(getString(R.string.cm_player_swipe_content));
                break;
            case 1:
                sv.setShowcase(new ViewTarget(mPlayerPageFragment.getImageArt()), true);
                sv.setContentTitle(getString(R.string.cm_player_lyrics_title));
                sv.setContentText(getString(R.string.cm_player_lyrics_content));
                break;
            case 2:
                sv.setButtonText(getString(R.string.cm_close));
                sv.setShowcase(new ViewTarget(mBtnPlayPause), true);
                sv.setContentTitle(getString(R.string.cm_player_hold_pause_title));
                sv.setContentText(getString(R.string.cm_player_hold_pause_content));
                break;
            case 3:
                sv.hide();
                break;
            }
            mShowcaseCounter++;
        }
    });

    RelativeLayout.LayoutParams lps = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    lps.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    lps.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    int margin = ((Number) (getResources().getDisplayMetrics().density * 12)).intValue();
    lps.setMargins(margin, margin * 3, margin, margin);

    sv.setButtonPosition(lps);
}

From source file:im.vector.activity.CallViewActivity.java

/**
 * Insert the callView in the activity (above the other room member)
 * @param avatarUrl the other member avatar
 *//*from w  w w  .  j  a v a2s.  c  o  m*/
private void insertCallView(String avatarUrl) {
    ImageView avatarView = (ImageView) CallViewActivity.this.findViewById(R.id.call_other_member);
    avatarView.setImageResource(R.drawable.ic_contact_picture_holo_light);

    if (!TextUtils.isEmpty(avatarUrl)) {
        int size = CallViewActivity.this.getResources().getDimensionPixelSize(R.dimen.member_list_avatar_size);
        mSession.getMediasCache().loadAvatarThumbnail(mSession.getHomeserverConfig(), avatarView, avatarUrl,
                size);
    }

    RelativeLayout layout = (RelativeLayout) CallViewActivity.this.findViewById(R.id.call_layout);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    layout.addView(mCallView, 1, params);

    mCall.setVisibility(View.GONE);
}

From source file:org.ednovo.goorusearchwidget.ResourcePlayer.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog = new ProgressDialog(this);
    prefsPrivate = getSharedPreferences(PREFS_PRIVATE, Context.MODE_PRIVATE);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    setContentViewLayout = new RelativeLayout(ResourcePlayer.this);
    prefsPrivate = getSharedPreferences(PREFS_PRIVATE, Context.MODE_PRIVATE);

    token = prefsPrivate.getString("token", "");

    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);

    Bundle extra = getIntent().getExtras();

    if (extra != null) {
        value = extra.getInt("key");
        gooruOID1 = extra.getStringArrayList("goor");

        searchkeyword = extra.getString("searchkey");
        limit = gooruOID1.size();//  w ww.  j  a v  a 2  s  .c  om
        gooruOID = gooruOID1.get(value);
        resourceGooruId = gooruOID;

        if (!gooruOID.isEmpty() || !gooruOID.equalsIgnoreCase("") || gooruOID != null) {
            if (checkInternetConnection()) {
                dialog = new ProgressDialog(ResourcePlayer.this);
                dialog.setTitle("gooru");
                dialog.setMessage("Please wait while loading...");
                dialog.setCancelable(false);
                dialog.show();
                new getResourcesInfo().execute();
            } else {

                dialog = new ProgressDialog(ResourcePlayer.this);
                dialog.setTitle("gooru");
                dialog.setMessage("No internet connection");
                dialog.show();
            }

        }
    }
    Editor prefsPrivateEditor = prefsPrivate.edit();

    // Authentication details
    prefsPrivateEditor.putString("searchkeyword", searchkeyword);
    prefsPrivateEditor.commit();

    wvPlayer = new WebView(ResourcePlayer.this);
    wvPlayer.resumeTimers();
    wvPlayer.getSettings().setJavaScriptEnabled(true);
    wvPlayer.getSettings().setPluginState(PluginState.ON);
    wvPlayer.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
    wvPlayer.setWebViewClient(new HelloWebViewClient());

    wvPlayer.setWebChromeClient(new MyWebChromeClient() {
    });
    wvPlayer.getSettings().setPluginsEnabled(true);
    new getResourcesInfo().execute();

    RelativeLayout temp = new RelativeLayout(ResourcePlayer.this);
    temp.setId(668);
    temp.setBackgroundColor(getResources().getColor(android.R.color.transparent));

    header = new RelativeLayout(ResourcePlayer.this);
    header.setId(1);

    header.setBackgroundDrawable(getResources().getDrawable(R.drawable.navbar));
    RelativeLayout.LayoutParams headerParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, 53);
    headerParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1);
    headerParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, -1);

    ivCloseIcon = new ImageView(ResourcePlayer.this);
    ivCloseIcon.setId(130);
    ivCloseIcon.setScaleType(ImageView.ScaleType.FIT_XY);
    RelativeLayout.LayoutParams ivCloseIconIconParams = new RelativeLayout.LayoutParams(50, 50);
    ivCloseIconIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1);
    ivCloseIconIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 1);
    ivCloseIcon.setPadding(0, 0, 0, 0);

    ivCloseIcon.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            finish();

        }
    });

    ivCloseIcon.setBackgroundDrawable(getResources().getDrawable(R.drawable.close_corner));
    header.addView(ivCloseIcon, ivCloseIconIconParams);

    ivmoveforward = new ImageView(ResourcePlayer.this);
    ivmoveforward.setId(222);
    if (value == limit - 1) {
        ivmoveforward.setVisibility(View.GONE);
    }
    ivmoveforward.setScaleType(ImageView.ScaleType.FIT_XY);
    RelativeLayout.LayoutParams ivmoveforwardIconIconParams = new RelativeLayout.LayoutParams(21, 38);

    ivmoveforwardIconIconParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, -1);
    ivmoveforwardIconIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1);
    ivmoveforwardIconIconParams.setMargins(0, 0, 30, 0);

    imageshare = new ImageView(ResourcePlayer.this);
    imageshare.setId(440);
    imageshare.setScaleType(ImageView.ScaleType.FIT_XY);
    RelativeLayout.LayoutParams imageshareIconParams = new RelativeLayout.LayoutParams(50, 50);
    imageshareIconParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, -1);
    imageshareIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1);
    imageshareIconParams.setMargins(0, 10, 100, 0);
    tvDescriptionn = new TextView(ResourcePlayer.this);
    tvDescriptionn1 = new TextView(ResourcePlayer.this);
    edittext_copyurl = new EditText(ResourcePlayer.this);
    imageshare.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            if (desc == 0) {
                new getShortUrl().execute();

                imageshare.setBackgroundDrawable(getResources().getDrawable(R.drawable.share_selected));

                subheader.setVisibility(View.VISIBLE);
                subheader.removeAllViews();

                tvDescriptionn.setVisibility(View.VISIBLE);
                tvDescriptionn1.setVisibility(View.VISIBLE);
                edittext_copyurl.setVisibility(View.VISIBLE);
                tvDescriptionn.setText("Share this with other by copying and pasting these links");
                tvDescriptionn.setId(221);

                tvDescriptionn.setTextSize(18);
                tvDescriptionn.setTypeface(null, Typeface.BOLD);
                tvDescriptionn.setTextColor(getResources().getColor(android.R.color.white));
                RelativeLayout.LayoutParams tvDescriptionParams = new RelativeLayout.LayoutParams(
                        RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
                tvDescriptionParams.setMargins(20, 10, 0, 20);
                subheader.addView(tvDescriptionn, tvDescriptionParams);

                tvDescriptionn1.setText("Collections");
                tvDescriptionn1.setId(226);

                tvDescriptionn1.setTextSize(18);
                tvDescriptionn1.setTypeface(null, Typeface.BOLD);
                tvDescriptionn1.setTextColor(getResources().getColor(android.R.color.white));
                RelativeLayout.LayoutParams tvDescriptionParams1 = new RelativeLayout.LayoutParams(
                        RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
                tvDescriptionParams1.setMargins(20, 42, 0, 20);
                subheader.addView(tvDescriptionn1, tvDescriptionParams1);

                edittext_copyurl.setId(266);

                edittext_copyurl.setTextSize(18);
                edittext_copyurl.setTypeface(null, Typeface.BOLD);
                edittext_copyurl.setTextColor(getResources().getColor(android.R.color.white));
                RelativeLayout.LayoutParams tvDescriptionParams11 = new RelativeLayout.LayoutParams(
                        RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
                tvDescriptionParams11.setMargins(130, 35, 0, 20);
                subheader.addView(edittext_copyurl, tvDescriptionParams11);
                desc = 1;
                flag = 0;

            } else {

                imageshare.setBackgroundDrawable(getResources().getDrawable(R.drawable.share_normal));
                subheader.removeAllViews();
                subheader.setVisibility(View.GONE);
                desc = 0;
            }
        }
    });

    imageshare.setBackgroundDrawable(getResources().getDrawable(R.drawable.share_normal));

    ivmoveforward.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (value < limit - 1) {
                Intent intentResPlayer = new Intent(getBaseContext(), ResourcePlayer.class);
                Bundle extras = new Bundle();
                // extras.putString("gooruOId",s);
                extras.putStringArrayList("goor", gooruOID1);
                value++;
                extras.putInt("key", value);
                intentResPlayer.putExtras(extras);
                urlcheck = 0;
                finish();
                startActivity(intentResPlayer);
            }

        }
    });

    ivmoveforward.setBackgroundDrawable(getResources().getDrawable(R.drawable.arrowright));

    ivmoveback = new ImageView(ResourcePlayer.this);
    ivmoveback.setId(220);
    if (value == 0) {
        ivmoveback.setVisibility(View.GONE);
    }
    ivmoveback.setScaleType(ImageView.ScaleType.FIT_XY);
    RelativeLayout.LayoutParams ivmovebackIconIconParams = new RelativeLayout.LayoutParams(21, 38);
    ivmovebackIconIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1);
    ivmovebackIconIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1);
    ivmovebackIconIconParams.setMargins(55, 0, 0, 0);

    ivmoveback.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            if (!(value <= 0)) {
                value--;
                Intent intentResPlayer = new Intent(getBaseContext(), ResourcePlayer.class);
                Bundle extras = new Bundle();
                extras.putStringArrayList("goor", gooruOID1);

                extras.putInt("key", value);
                intentResPlayer.putExtras(extras);
                urlcheck = 0;
                finish();
                startActivity(intentResPlayer);
            }

        }
    });

    ivmoveback.setBackgroundDrawable(getResources().getDrawable(R.drawable.left));

    webViewBack = new ImageView(ResourcePlayer.this);
    webViewBack.setId(323);
    webViewBack.setScaleType(ImageView.ScaleType.FIT_XY);

    RelativeLayout.LayoutParams webViewBackIconParams = new RelativeLayout.LayoutParams(25, 26);

    webViewBackIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1);
    webViewBackIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1);
    webViewBackIconParams.setMargins(175, 0, 0, 0);

    webViewBack.setBackgroundDrawable(getResources().getDrawable(R.drawable.arrow_leftactive));
    webViewBack.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (wvPlayer.canGoBack()) {

                wvPlayer.goBack();

            }

        }
    });

    webViewRefresh = new ImageView(ResourcePlayer.this);
    webViewRefresh.setId(322);
    webViewRefresh.setScaleType(ImageView.ScaleType.FIT_XY);

    RelativeLayout.LayoutParams webViewRefreshIconParams = new RelativeLayout.LayoutParams(30, 30);

    webViewRefreshIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1);
    webViewRefreshIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1);
    webViewRefreshIconParams.setMargins(305, 0, 0, 0);

    webViewRefresh.setBackgroundDrawable(getResources().getDrawable(R.drawable.refresh));
    webViewRefresh.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            wvPlayer.reload();
        }
    });

    webViewForward = new ImageView(ResourcePlayer.this);
    webViewForward.setId(321);
    webViewForward.setScaleType(ImageView.ScaleType.FIT_XY);
    RelativeLayout.LayoutParams webViewForwardIconParams = new RelativeLayout.LayoutParams(25, 26);

    webViewForwardIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1);
    webViewForwardIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1);
    webViewForwardIconParams.setMargins(245, 0, 0, 0);
    webViewForward.setBackgroundDrawable(getResources().getDrawable(R.drawable.arrow_rightactive));
    webViewForward.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (wvPlayer.canGoForward()) {

                wvPlayer.goForward();

            }
        }
    });

    ivResourceIcon = new ImageView(ResourcePlayer.this);
    ivResourceIcon.setId(30);
    ivResourceIcon.setScaleType(ImageView.ScaleType.FIT_XY);
    RelativeLayout.LayoutParams ivResourceIconParams = new RelativeLayout.LayoutParams(50, 25);
    ivResourceIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1);
    ivResourceIconParams.addRule(RelativeLayout.LEFT_OF, 130);
    ivResourceIcon.setPadding(50, 0, 0, 0);

    ivResourceIcon.setBackgroundDrawable(getResources().getDrawable(R.drawable.handouts));
    header.addView(ivResourceIcon, ivResourceIconParams);

    tvLearn = new TextView(this);
    tvLearn.setText("Learn More");
    tvLearn.setId(20);
    tvLearn.setPadding(100, 0, 0, 0);
    tvLearn.setTextSize(20);
    tvLearn.setTextColor(getResources().getColor(android.R.color.white));
    RelativeLayout.LayoutParams tvLearnParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    tvLearnParams.addRule(RelativeLayout.CENTER_VERTICAL, 1);
    tvLearnParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 1);
    tvAbout = new ImageView(ResourcePlayer.this);
    tvAbout.setId(21);
    tvAbout.setScaleType(ImageView.ScaleType.FIT_XY);
    RelativeLayout.LayoutParams webViewForwardIconParamsa = new RelativeLayout.LayoutParams(32, 32);

    webViewForwardIconParamsa.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, -1);

    webViewForwardIconParamsa.addRule(RelativeLayout.CENTER_VERTICAL, -1);
    webViewForwardIconParamsa.setMargins(0, 0, 200, 0);

    tvAbout.setBackgroundDrawable(getResources().getDrawable(R.drawable.info));

    header.addView(tvAbout, webViewForwardIconParamsa);

    RelativeLayout fortvtitle = new RelativeLayout(this);
    RelativeLayout.LayoutParams tvTitleParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    tvTitleParams.addRule(RelativeLayout.CENTER_HORIZONTAL, 1);
    tvTitleParams.addRule(RelativeLayout.CENTER_VERTICAL, 1);
    tvTitleParams.addRule(RelativeLayout.RIGHT_OF, 322);
    tvTitleParams.addRule(RelativeLayout.LEFT_OF, 21);
    header.addView(fortvtitle, tvTitleParams);

    tvTitle = new TextView(this);
    tvTitle.setText("");
    tvTitle.setId(22);
    tvTitle.setPadding(0, 0, 0, 0);
    tvTitle.setTextSize(25);
    tvTitle.setSingleLine(true);
    tvTitle.setTextColor(getResources().getColor(android.R.color.white));
    RelativeLayout.LayoutParams tvTitleParamstv = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

    tvTitleParamstv.addRule(RelativeLayout.CENTER_HORIZONTAL, 1);
    tvTitleParamstv.addRule(RelativeLayout.CENTER_VERTICAL, 1);

    fortvtitle.addView(tvTitle, tvTitleParamstv);

    tvViewsNLikes = new TextView(this);
    tvViewsNLikes.setText("");
    tvViewsNLikes.setId(23);
    tvViewsNLikes.setPadding(0, 0, 5, 5);
    tvViewsNLikes.setTextSize(18);
    tvViewsNLikes.setTextColor(getResources().getColor(android.R.color.white));
    RelativeLayout.LayoutParams tvViewsNLikesParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

    tvViewsNLikesParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 1);
    tvViewsNLikesParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 1);

    subheader = new RelativeLayout(ResourcePlayer.this);
    subheader.setId(100);
    subheader.setVisibility(View.GONE);
    subheader.setBackgroundDrawable(getResources().getDrawable(R.drawable.navbar));

    RelativeLayout.LayoutParams subheaderParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.FILL_PARENT, 100);
    subheaderParams.addRule(RelativeLayout.BELOW, 1);
    subheaderParams.addRule(RelativeLayout.CENTER_IN_PARENT, 1);

    RelativeLayout.LayoutParams wvPlayerParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
    wvPlayerParams.addRule(RelativeLayout.BELOW, 100);
    wvPlayerParams.addRule(RelativeLayout.CENTER_IN_PARENT, 100);

    LinearLayout videoLayout = new LinearLayout(this);
    videoLayout.setVisibility(View.GONE);

    header.addView(webViewBack, webViewBackIconParams);
    header.addView(webViewRefresh, webViewRefreshIconParams);
    header.addView(webViewForward, webViewForwardIconParams);
    header.addView(ivmoveforward, ivmoveforwardIconIconParams);
    header.addView(imageshare, imageshareIconParams);
    header.addView(ivmoveback, ivmovebackIconIconParams);
    temp.addView(header, headerParams);
    temp.addView(subheader, subheaderParams);
    temp.addView(wvPlayer, wvPlayerParams);
    temp.addView(videoLayout, wvPlayerParams);

    setContentViewLayout.addView(temp, layoutParams);

    setContentView(setContentViewLayout);
    tvDescription = new TextView(ResourcePlayer.this);
    tvDescription1 = new TextView(ResourcePlayer.this);
    tvAbout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (flag == 0) {
                subheader.setVisibility(View.VISIBLE);
                subheader.removeAllViews();
                // tvDescriptionn.setVisibility(View.INVISIBLE);
                tvDescription1.setVisibility(View.VISIBLE);
                tvDescription.setVisibility(View.VISIBLE);

                tvDescription.setText("Description");
                tvDescription.setId(221);

                tvDescription.setTextSize(18);
                tvDescription.setTypeface(null, Typeface.BOLD);
                tvDescription.setTextColor(getResources().getColor(android.R.color.white));
                RelativeLayout.LayoutParams tvDescriptionParams = new RelativeLayout.LayoutParams(
                        RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
                tvDescriptionParams.setMargins(20, 10, 0, 20);
                tvDescriptionParams.addRule(RelativeLayout.BELOW, 220);

                tvDescription1.setText(description);
                tvDescription1.setLines(3);
                tvDescription1.setId(321);

                tvDescription1.setTextSize(15);
                tvDescription1.setTextColor(getResources().getColor(android.R.color.white));
                RelativeLayout.LayoutParams tvDescription1Params = new RelativeLayout.LayoutParams(1100, 100);
                tvDescription1Params.addRule(RelativeLayout.CENTER_IN_PARENT, -1);
                tvDescription1.setPadding(100, 20, 100, 0);
                subheader.addView(tvDescription1, tvDescription1Params);
                desc = 0;
                flag = 1;
                flag1 = 0;

            } else {
                subheader.removeAllViews();
                subheader.setVisibility(View.GONE);

                flag = 0;
            }
        }
    });

}

From source file:com.kaltura.playersdk.PlayerViewController.java

/**
 * Sets the player's dimensions. Should be called for any player redraw
 * (for example, in screen rotation, if supported by the main activity)
 * @param width player's width//from w w w. jav a  2 s . com
 * @param height player's height
 * @param xPadding player's X position
 * @param yPadding player's Y position
 */
public void setPlayerViewDimensions(int width, int height, int xPadding, int yPadding) {
    setPadding(xPadding, yPadding, 0, 0);
    newWidth = width + xPadding;
    newHeight = height + yPadding;

    ViewGroup.LayoutParams lp = getLayoutParams();
    if (lp == null) {
        lp = new ViewGroup.LayoutParams(newWidth, newHeight);
    } else {
        lp.width = newWidth;
        lp.height = newHeight;
    }

    this.setLayoutParams(lp);
    for (int i = 0; i < this.getChildCount(); i++) {

        View v = getChildAt(i);
        if (v == mVideoInterface) {
            continue;
        }
        ViewGroup.LayoutParams vlp = v.getLayoutParams();
        vlp.width = newWidth;
        if ((!mWvMinimized || !v.equals(mWebView))) {//
            vlp.height = newHeight;
        }
        updateViewLayout(v, vlp);
    }

    if (mWebView != null) {
        // mWebView.loadUrl("javascript:android.onData(NativeBridge.videoPlayer.getControlBarHeight())");
        mWebView.fetchControlsBarHeight(new KControlsView.ControlsBarHeightFetcher() {
            @Override
            public void fetchHeight(int controlBarHeight) {
                if (mVideoInterface != null && mVideoInterface.getParent() == PlayerViewController.this) {
                    LayoutParams wvLp = (LayoutParams) ((View) mVideoInterface).getLayoutParams();

                    if (getPaddingLeft() == 0 && getPaddingTop() == 0) {
                        wvLp.addRule(CENTER_IN_PARENT);
                    } else {
                        wvLp.addRule(CENTER_IN_PARENT, 0);
                    }
                    float scale = mActivity.getResources().getDisplayMetrics().density;
                    controlBarHeight = (int) (controlBarHeight * scale + 0.5f);
                    wvLp.height = newHeight - controlBarHeight;
                    wvLp.width = newWidth;
                    wvLp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
                    final LayoutParams lp = wvLp;
                    mActivity.runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            updateViewLayout(mVideoInterface, lp);
                            invalidate();
                        }
                    });

                }
            }
        });
    }
    invalidate();
}

From source file:com.frostytornado.cordova.plugin.ad.admob.Util.java

protected void addBannerViewOverlap(String position, String size) {
    removeBannerViewOverlap();/*www .j  a  va2s.c  o  m*/

    if (bannerViewLayout == null) {
        bannerViewLayout = new RelativeLayout(plugin.getCordova().getActivity());//   
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
        bannerViewLayout.setLayoutParams(params);
        ((ViewGroup) getView(plugin.getWebView())).addView(bannerViewLayout);

        params = new RelativeLayout.LayoutParams(AdView.LayoutParams.WRAP_CONTENT,
                AdView.LayoutParams.WRAP_CONTENT);
        if (position.equals("top-left")) {
            Log.d(LOG_TAG, "top-left");
            params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
            params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
        } else if (position.equals("top-center")) {
            params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
            params.addRule(RelativeLayout.CENTER_HORIZONTAL);
        } else if (position.equals("top-right")) {
            params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
            params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        } else if (position.equals("left")) {
            params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
            params.addRule(RelativeLayout.CENTER_VERTICAL);
        } else if (position.equals("center")) {
            params.addRule(RelativeLayout.CENTER_HORIZONTAL);
            params.addRule(RelativeLayout.CENTER_VERTICAL);
        } else if (position.equals("right")) {
            params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
            params.addRule(RelativeLayout.CENTER_VERTICAL);
        } else if (position.equals("bottom-left")) {
            params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
            params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
        } else if (position.equals("bottom-center")) {
            params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
            params.addRule(RelativeLayout.CENTER_HORIZONTAL);
        } else if (position.equals("bottom-right")) {
            params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
            params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        } else {
            params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
            params.addRule(RelativeLayout.CENTER_HORIZONTAL);
        }

        bannerView.setLayoutParams(params);
        bannerViewLayout.addView(bannerView);
    }
}