Example usage for android.widget RelativeLayout ALIGN_PARENT_LEFT

List of usage examples for android.widget RelativeLayout ALIGN_PARENT_LEFT

Introduction

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

Prototype

int ALIGN_PARENT_LEFT

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

Click Source Link

Document

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

Usage

From source file:com.spoiledmilk.ibikecph.navigation.SMRouteNavigationActivity.java

@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.setContentView(R.layout.route_navigation_activity);
    LayoutInflater inflater = LayoutInflater.from(this);
    reportProblemsView = (RelativeLayout) inflater.inflate(R.layout.report_problems_view, null);
    textReport = (TextView) reportProblemsView.findViewById(R.id.textReport);

    instructionsViewMaxContainer = (RelativeLayout) findViewById(R.id.instructionsViewMaxContainer);
    paramsForInstMaxContainer = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
            RelativeLayout.LayoutParams.MATCH_PARENT);
    paramsForInstMaxContainer.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    paramsForInstMaxContainer.addRule(RelativeLayout.CENTER_HORIZONTAL);
    paramsForInstMaxContainer.topMargin = 0;
    instructionsViewMaxContainer.setLayoutParams(paramsForInstMaxContainer);

    routeFinishedContainer = (RelativeLayout) findViewById(R.id.routeFinishedContainer);
    imgClose = (ImageButton) findViewById(R.id.imgClose);
    imgClose.setOnClickListener(new OnClickListener() {
        @Override/*from   ww  w  .  j a va  2s.c  om*/
        public void onClick(View arg0) {
            Bundle conData = new Bundle();
            conData.putInt("overlaysShown", getOverlaysShown());
            Intent intent = new Intent();
            intent.putExtras(conData);
            setResult(MapActivity.RESULT_RETURN_FROM_NAVIGATION, intent);
            setResult(MapActivity.RESULT_RETURN_FROM_NAVIGATION);
            finish();
            overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
        }

    });
    progressBar = (ProgressBar) findViewById(R.id.progressBar);
    textGoodRide = (TextView) findViewById(R.id.textGoodRide);
    textRecalculating = (TextView) findViewById(R.id.textRecalculating);
    textBicycle = (TextView) findViewById(R.id.textBicycle);
    textCargo = (TextView) findViewById(R.id.textCargo);
    textGreen = (TextView) findViewById(R.id.textGreen);
    FrameLayout.LayoutParams rootParams = new FrameLayout.LayoutParams((int) (9 * Util.getScreenWidth() / 5),
            FrameLayout.LayoutParams.MATCH_PARENT);
    findViewById(R.id.root_layout).setLayoutParams(rootParams);
    this.maxSlide = (int) (4 * Util.getScreenWidth() / 5);
    Util.init(getWindowManager());
    leftContainer = (RelativeLayout) findViewById(R.id.leftContainer);
    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);
    leftContainer.setLayoutParams(params);
    parentContainer = (RelativeLayout) findViewById(R.id.parent_container);
    params = new RelativeLayout.LayoutParams((int) Util.getScreenWidth(),
            RelativeLayout.LayoutParams.MATCH_PARENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    parentContainer.setLayoutParams(params);
    imgCargoSlider = (ImageView) findViewById(R.id.imgCargoSlider);
    imgCargoSlider.setOnTouchListener(new OnTouchListener() {
        // Swipe the view horizontally
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return onSliderTouch(v, event);
        }

    });

    darkenedView = findViewById(R.id.darkenedView);
    darkenedView.setBackgroundColor(Color.BLACK);
    viewDistance = (RelativeLayout) findViewById(R.id.viewDistance);
    textTime = (TextView) findViewById(R.id.textTime);

    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 onSliderTouch(v, event);
        }

    });

    paramsInstructionsMaxNormal.topMargin = (int) (Util.getScreenHeight() - Util.dp2px(146));
    paramsInstructionsMaxNormal.bottomMargin = -(int) ((Util.getScreenHeight()));
    paramsInstructionsMaxMaximized.topMargin = INSTRUCTIONS_TOP_MARGIN;
    paramsInstructionsMaxMinimized.topMargin = (int) (Util.getScreenHeight() - Util.getScreenHeight() / 10);
    paramsInstructionsMaxMinimized.bottomMargin = -(int) ((Util.getScreenHeight()));

    overviewLayout = (RelativeLayout) findViewById(R.id.overviewLayout);

    btnStart = (Button) overviewLayout.findViewById(R.id.btnStart);
    btnStart.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            viewDistance.setVisibility(View.VISIBLE);
            btnStart.setEnabled(false);
            hideOverview();
            textTime.setText(mapFragment.getEstimatedArrivalTime());
            mapFragment.startRouting();
            IbikeApplication.getTracker().sendEvent("Route", "Overview", mapFragment.destination, (long) 0);
            // instructionsView.setVisibility(View.VISIBLE);
            setInstructionViewState(InstrcutionViewState.Normal);
            RelativeLayout.LayoutParams paramsBtnTrack = new RelativeLayout.LayoutParams(
                    RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
            paramsBtnTrack.setMargins(Util.dp2px(10), Util.dp2px(10), Util.dp2px(10), Util.dp2px(10));
            paramsBtnTrack.alignWithParent = true;
            paramsBtnTrack.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
            paramsBtnTrack.addRule(RelativeLayout.ABOVE, instructionsView.getId());
            btnTrack.setLayoutParams(paramsBtnTrack);
            startTrackingUser();
        }
    });

    btnClose = ((ImageButton) findViewById(R.id.btnClose));
    btnClose.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            showStopDlg();
        }
    });

    // Darken the button on touch :
    btnClose.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View arg0, MotionEvent me) {
            if (me.getAction() == MotionEvent.ACTION_DOWN) {
                btnClose.setColorFilter(Color.argb(150, 155, 155, 155));
                return false;
            } else if (me.getAction() == MotionEvent.ACTION_UP || me.getAction() == MotionEvent.ACTION_CANCEL) {
                btnClose.setColorFilter(Color.argb(0, 155, 155, 155));
                return false;
            }
            return false;
        }

    });

    // increased touch area for the normal pull handle
    pullTouchNormal = findViewById(R.id.pullTouchNormal);
    pullTouchNormal.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View arg0, MotionEvent event) {
            isPulledFromNormal = true;
            return onPullHandleTouch(null, event);
        }
    });

    // increased touch area for the max pull handle
    pullTouchMax = findViewById(R.id.pullTouchMax);
    pullTouchMax.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View arg0, MotionEvent event) {
            isPulledFromNormal = false;
            yFix = Util.dp2px(16);
            return onPullHandleTouch(null, event);
        }
    });

    mapTopDisabledView = findViewById(R.id.mapTopDisabledView);
    mapTopDisabledView.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View arg0, MotionEvent event) {
            isPulledFromNormal = false;
            yFix = Util.dp2px(42);
            // return onPullHandleTouch(null, event);
            return true;
        }
    });

    instructionsView = (RelativeLayout) findViewById(R.id.instructionsView);
    instructionsView.setBackgroundColor(Color.BLACK);
    pullHandle = (ImageButton) instructionsView.findViewById(R.id.imgPullHandle);
    pullHandle.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View arg0, MotionEvent event) {
            isPulledFromNormal = true;
            return onPullHandleTouch(null, event);
        }

    });

    instructionsViewMin = (LinearLayout) findViewById(R.id.instructionsViewMin);
    pullHandleMin = (ImageButton) instructionsViewMin.findViewById(R.id.imgPullHandleMin);
    pullHandleMin.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View arg0, MotionEvent arg1) {
            return onPullHandleTouch(arg0, arg1);
        }

    });

    instructionsViewMax = (RelativeLayout) findViewById(R.id.instructionsViewMax);
    params = new RelativeLayout.LayoutParams((int) Util.getScreenWidth(),
            RelativeLayout.LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    instructionsView.setLayoutParams(params);
    params = new RelativeLayout.LayoutParams((int) Util.getScreenWidth(),
            RelativeLayout.LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    findViewById(R.id.overviewLayout).setLayoutParams(params);
    pullHandleMax = (ImageButton) instructionsViewMax.findViewById(R.id.imgPullHandleMax);
    pullHandleMax.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View arg0, MotionEvent arg1) {
            isPulledFromNormal = false;
            return onPullHandleTouch(arg0, arg1);
        }

    });

    instructionList = (ListView) instructionsViewMax.findViewById(R.id.listView);
    instructionList.addFooterView(reportProblemsView);
    setInstructionViewState(InstrcutionViewState.Invisible);

    FragmentManager fm = this.getSupportFragmentManager();
    mapFragment = getMapFragment();
    fm.beginTransaction().add(R.id.map_container, mapFragment).commit();

    viewPager = (ViewPager) instructionsView.findViewById(R.id.viewPager);
    // viewPager = (ViewPager) findViewById(R.id.viewPager);
    viewPager.setOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            if (!instructionsUpdated || (mapFragment.isRecalculation && !mapFragment.getTrackingMode())) {
                SMTurnInstruction turn = mapFragment.route.getTurnInstructions().get(position);
                if (turn.drivingDirection == SMTurnInstruction.TurnDirection.ReachedYourDestination
                        || turn.drivingDirection == SMTurnInstruction.TurnDirection.ReachingDestination) {
                    mapFragment.animateTo(mapFragment.route.getEndLocation());
                } else {
                    mapFragment.animateTo(turn.getLocation());
                }
                stopTrackingUser();
            }
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {

        }

        @Override
        public void onPageScrollStateChanged(int arg0) {

        }
    });

    pagerAdapter = getPagerAdapter();
    viewPager.setAdapter(pagerAdapter);
    viewPager.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // used to disable viewPager swiping when the left menu is
            // opened
            return slidden;
        }
    });

    btnTrack = (ImageButton) findViewById(R.id.btnTrack);
    btnTrack.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!mapFragment.getTrackingMode()) {
                startTrackingUser();
            } else {
                mapFragment.switchTracking();
                changeTrackingIcon();
            }
        }

    });

    textReport.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            launchReportIssuesActivity();
        }

    });

    textReport2 = (TextView) findViewById(R.id.textReport2);
    textReport2.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            launchReportIssuesActivity();
        }

    });
    textDestAddress = (TextView) findViewById(R.id.textDestAddress);
    textDestAddress.setTypeface(IbikeApplication.getNormalFont());
    Config.OSRM_SERVER = Config.OSRM_SERVER_FAST;

    if (savedInstanceState != null) {
        final Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                Intent intent = new Intent(SMRouteNavigationActivity.this, getSplashActivityClass());
                intent.putExtra("timeout", 0);
                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(intent);
                finish();
            }
        }, 400);
    }

    instructionsViewMax.setLayoutParams(paramsInstructionsMaxNormal);

    RelativeLayout.LayoutParams paramsBtnTrack = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    paramsBtnTrack.setMargins(Util.dp2px(10), Util.dp2px(10), Util.dp2px(10), Util.dp2px(10));
    paramsBtnTrack.alignWithParent = true;
    paramsBtnTrack.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    paramsBtnTrack.addRule(RelativeLayout.ABOVE, overviewLayout.getId());
    btnTrack.setLayoutParams(paramsBtnTrack);

    instructionsView.measure(0, 0);
    instructionsViewHeight = instructionsView.getMeasuredHeight();

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}

From source file:com.orangelabs.rcs.ri.messaging.chat.ChatCursorAdapter.java

private void bindFileTransferMessage(Cursor cursor, Direction dir, String displayName, int status,
        ViewHolderFileTransfer holder) {
    RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
            RelativeLayout.LayoutParams.WRAP_CONTENT);
    String mimeType = cursor.getString(holder.columnMimetype);
    // TODO display distinct icon or thumbnail depending on the mimetype
    holder.statusText.setText(RiApplication.sFileTransferStates[status]);
    StringBuilder filename = new StringBuilder(cursor.getString(holder.columnFilename));
    long filesize = cursor.getLong(holder.columnFilesize);
    long transferred = cursor.getLong(holder.columnTransferred);

    if (filesize != transferred) {
        holder.progressText.setText(//w w  w  .j a  va 2s  . c o  m
                filename.append(" : ").append(Utils.getProgressLabel(transferred, filesize)).toString());
        holder.fileImageOutgoing.setImageResource(R.drawable.ri_filetransfer_off);
        holder.fileImageIncoming.setImageResource(R.drawable.ri_filetransfer_off);
    } else {
        int reason = cursor.getInt(holder.columnReasonCode);
        FileTransfer.ReasonCode reasonCode = FileTransfer.ReasonCode.valueOf(reason);
        if (FileTransfer.ReasonCode.UNSPECIFIED == reasonCode) {
            holder.fileImageOutgoing.setImageResource(R.drawable.ri_filetransfer_on);
            holder.fileImageIncoming.setImageResource(R.drawable.ri_filetransfer_on);
        } else {
            holder.fileImageOutgoing.setImageResource(R.drawable.ri_filetransfer_off);
            holder.fileImageIncoming.setImageResource(R.drawable.ri_filetransfer_off);
        }
        holder.progressText.setText(filename.append(" (").append(filesize / 1024).append(" Kb)").toString());
    }
    if (Direction.OUTGOING == dir) {
        boolean undeliveredExpiration = cursor.getInt(holder.columnExpiredDelivery) == 1;
        holder.undeliveredIcon.setVisibility(undeliveredExpiration ? View.VISIBLE : View.GONE);
        holder.contactText.setVisibility(View.INVISIBLE);
        holder.fileImageIncoming.setVisibility(View.GONE);
        holder.fileImageOutgoing.setVisibility(View.VISIBLE);
        lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    } else {
        holder.undeliveredIcon.setVisibility(View.GONE);
        holder.fileImageIncoming.setVisibility(View.VISIBLE);
        holder.fileImageOutgoing.setVisibility(View.GONE);
        if (displayName != null) {
            holder.contactText.setVisibility(View.VISIBLE);
            holder.contactText.setText(displayName);
        } else {
            holder.contactText.setVisibility(View.INVISIBLE);
        }
        lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    }
    holder.filetransferItemLayout.setLayoutParams(lp);
}

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

/**
 * Initializes the UI and creates the detector pipeline.
 *//*from w  w w.j a  v  a 2s.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   w w  w .j a  va 2s . 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());/* w w  w . j a va2  s  .co  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:ti.modules.titanium.ui.widget.TiUIScrollableView.java

private RelativeLayout buildPagingControl(Context context) {
    RelativeLayout layout = new RelativeLayout(context);
    layout.setFocusable(false);//from   ww  w  .  j av a  2s . c  o m
    layout.setFocusableInTouchMode(false);

    TiArrowView left = new TiArrowView(context);
    left.setVisibility(View.INVISIBLE);
    left.setId(PAGE_LEFT);
    left.setMinimumWidth(80); // TODO density?
    left.setMinimumHeight(80);
    left.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (mEnabled) {
                movePrevious();
            }
        }
    });
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    params.addRule(RelativeLayout.CENTER_VERTICAL);
    layout.addView(left, params);

    TiArrowView right = new TiArrowView(context);
    right.setLeft(false);
    right.setVisibility(View.INVISIBLE);
    right.setId(PAGE_RIGHT);
    right.setMinimumWidth(80); // TODO density?
    right.setMinimumHeight(80);
    right.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (mEnabled) {
                moveNext();
            }
        }
    });
    params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    params.addRule(RelativeLayout.CENTER_VERTICAL);
    layout.addView(right, params);

    layout.setVisibility(View.GONE);

    return layout;
}

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  ww. j a v  a 2  s  .  c om*/
        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:com.pemikir.youtubeplus.VideoItemDetailFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceBundle) {
    super.onActivityCreated(savedInstanceBundle);
    FloatingActionButton playVideoButton = (FloatingActionButton) getActivity()
            .findViewById(R.id.playVideoButton);

    if (PreferenceManager.getDefaultSharedPreferences(getActivity())
            .getBoolean(getString(R.string.leftHandLayout), false) && checkIfLandscape()) {
        RelativeLayout.LayoutParams oldLayout = (RelativeLayout.LayoutParams) playVideoButton.getLayoutParams();
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
        layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
        layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
        layoutParams.setMargins(oldLayout.leftMargin, oldLayout.topMargin, oldLayout.rightMargin,
                oldLayout.rightMargin);/*from   ww w . j  a  v a2s  .  c o m*/
        playVideoButton.setLayoutParams(layoutParams);
    }

    playVideoButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ActionBarHandler.getHandler().playVideo();
        }
    });
}

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

/**
 * Add a TextView containing the help text to the default location.
 * Override to reposition.// w  ww  .j a v  a  2  s . c  om
 */
protected void addHelpTextView(View v) {
    if (v == null) {
        Timber.e("cannot add a null view as helpTextView");
        return;
    }

    // default for helptext
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    params.addRule(RelativeLayout.BELOW, questionMediaLayout.getId());
    params.setMargins(10, 0, 10, 0);
    addView(v, params);
}

From source file:com.adithyaupadhya.uimodule.roundcornerprogressbar.BaseRoundCornerProgressBar.java

private void setupReverse(LinearLayout layoutProgress) {
    RelativeLayout.LayoutParams progressParams = (RelativeLayout.LayoutParams) layoutProgress.getLayoutParams();
    removeLayoutParamsRule(progressParams);
    if (isReverse) {
        progressParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        // For support with RTL on API 17 or more
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
            progressParams.addRule(RelativeLayout.ALIGN_PARENT_END);
    } else {/*from   ww w .jav  a2  s .c o m*/
        progressParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
        // For support with RTL on API 17 or more
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
            progressParams.addRule(RelativeLayout.ALIGN_PARENT_START);
    }
    layoutProgress.setLayoutParams(progressParams);
}