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.androidhiddencamera.HiddenCameraActivity.java

/**
 * Add camera preview to the root of the activity layout.
 *
 * @return {@link CameraPreview} that was added to the view.
 */// w w  w  . j a  v a2  s  .co m
private CameraPreview addPreView() {
    //create fake camera view
    CameraPreview cameraSourceCameraPreview = new CameraPreview(this, this);
    cameraSourceCameraPreview.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    View view = ((ViewGroup) getWindow().getDecorView().getRootView()).getChildAt(0);

    if (view instanceof LinearLayout) {
        LinearLayout linearLayout = (LinearLayout) view;

        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(1, 1);
        linearLayout.addView(cameraSourceCameraPreview, params);
    } else if (view instanceof RelativeLayout) {
        RelativeLayout relativeLayout = (RelativeLayout) view;

        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(1, 1);
        params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
        params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
        relativeLayout.addView(cameraSourceCameraPreview, params);
    } else if (view instanceof FrameLayout) {
        FrameLayout frameLayout = (FrameLayout) view;

        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(1, 1);
        frameLayout.addView(cameraSourceCameraPreview, params);
    } else {
        throw new RuntimeException("Root view of the activity/fragment cannot be frame layout");
    }

    return cameraSourceCameraPreview;
}

From source file:com.xalops.spotifystreamer.fragments.SearchListFragment.java

/**
 * Provide default implementation to return a simple list view.  Subclasses
 * can override to replace with their own layout.  If doing so, the
 * returned view hierarchy <em>must</em> have a ListView whose id
 * is {@link android.R.id#list android.R.id.list} and can optionally
 * have a sibling view id {@link android.R.id#empty android.R.id.empty}
 * that is to be shown when the list is empty.
 *
 * <p>If you are overriding this method with your own custom content,
 * consider including the standard layout {@link android.R.layout#list_content}
 * in your layout file, so that you continue to retain all of the standard
 * behavior of ListFragment.  In particular, this is currently the only
 * way to have the built-in indeterminant progress state be shown.
 *///from w ww.java 2s .c o  m
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = getActivity();
    FrameLayout root = new FrameLayout(context);

    //QUICK Inflate from XML file

    //inflater.inflate(R.layout.search_list_detail, root);
    // ------------------------------------------------------------------

    LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(LinearLayout.VERTICAL);
    pframe.setVisibility(View.GONE);
    pframe.setGravity(Gravity.CENTER);

    ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);
    pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    RelativeLayout rlayout = new RelativeLayout(context);

    EditText et = new EditText(getActivity());
    et.setId(INTERNAL_SEARCH_FIELD_ID);
    et.setSingleLine(true);
    et.setInputType(InputType.TYPE_CLASS_TEXT);
    et.setImeOptions(EditorInfo.IME_ACTION_DONE);
    RelativeLayout.LayoutParams etRLayoutParams = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    etRLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    etRLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);

    FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);
    RelativeLayout.LayoutParams lframeRLayoutParams = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    lframeRLayoutParams.addRule(RelativeLayout.BELOW, INTERNAL_SEARCH_FIELD_ID);

    TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    ListView lv = new ListView(getActivity());
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    rlayout.addView(et, etRLayoutParams);
    rlayout.addView(lframe, lframeRLayoutParams);
    root.addView(rlayout, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    return root;
}

From source file:fr.cph.stock.android.activity.AccountActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.v(TAG, "Account Activity onCreate");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.account_activity);

    Bundle b = getIntent().getExtras();//from   w w w. j  a  v a2  s . c o m
    portfolio = b.getParcelable("portfolio");

    errorView = (TextView) findViewById(R.id.errorMessage);
    totalValueView = (TextView) findViewById(R.id.totalValue);
    totalGainView = (TextView) findViewById(R.id.totalGain);
    totalPlusMinusValueView = (TextView) findViewById(R.id.totalPlusMinusValue);
    lastUpateView = (TextView) findViewById(R.id.lastUpdate);
    liquidityView = (TextView) findViewById(R.id.liquidity);
    yieldYearView = (TextView) findViewById(R.id.yieldYear);
    shareValueView = (TextView) findViewById(R.id.shareValue);
    gainView = (TextView) findViewById(R.id.gain2);
    perfView = (TextView) findViewById(R.id.perf);
    yieldView = (TextView) findViewById(R.id.yieldPerf);
    taxesView = (TextView) findViewById(R.id.taxes);

    RelativeLayout accLayout = (RelativeLayout) findViewById(R.id.accountsLayout);
    TextView recent = new TextView(getApplicationContext());
    textViews = new ArrayList<TextView>();
    int id = 1;
    int nameID = 100;
    int viewId1 = 500;
    int currencyId = 1000;
    for (int i = 0; i < portfolio.getAccounts().size(); i++) {
        Account account = portfolio.getAccounts().get(i);
        TextView currentAccountNameTextView = new TextView(getApplicationContext());
        currentAccountNameTextView.setText(account.getName());
        currentAccountNameTextView.setTextColor(Color.GRAY);
        currentAccountNameTextView.setId(nameID);
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams((int) LayoutParams.WRAP_CONTENT,
                (int) LayoutParams.WRAP_CONTENT);
        if (i != 0) {
            params.addRule(RelativeLayout.BELOW, recent.getId());
        }
        params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
        currentAccountNameTextView.setLayoutParams(params);
        accLayout.addView(currentAccountNameTextView, params);
        textViews.add(currentAccountNameTextView);

        View viewPoint1 = new View(getApplicationContext());
        viewPoint1.setId(viewId1);
        viewPoint1.setBackgroundColor(getResources().getColor(R.color.grey_light));
        params = new RelativeLayout.LayoutParams((int) LayoutParams.MATCH_PARENT, 2);
        params.addRule(RelativeLayout.RIGHT_OF, nameID);
        params.addRule(RelativeLayout.LEFT_OF, currencyId);
        params.setMargins(0, Util.convertDpToPxl(15, getApplicationContext()), 0, 0);
        if (i != 0) {
            params.addRule(RelativeLayout.BELOW, recent.getId());
        }
        viewPoint1.setLayoutParams(params);
        accLayout.addView(viewPoint1, params);

        TextView currentCurrencyTextView = new TextView(getApplicationContext());
        currentCurrencyTextView.setText(account.getCurrency());
        currentCurrencyTextView.setTextColor(Color.GRAY);
        currentCurrencyTextView.setId(currencyId);
        params = new RelativeLayout.LayoutParams((int) LayoutParams.WRAP_CONTENT,
                (int) LayoutParams.WRAP_CONTENT);
        params.addRule(RelativeLayout.CENTER_HORIZONTAL);
        if (i != 0) {
            params.addRule(RelativeLayout.BELOW, recent.getId());
        }
        currentCurrencyTextView.setLayoutParams(params);
        accLayout.addView(currentCurrencyTextView, params);
        textViews.add(currentCurrencyTextView);

        View viewPoint2 = new View(getApplicationContext());
        viewPoint2.setBackgroundColor(getResources().getColor(R.color.grey_light));
        params = new RelativeLayout.LayoutParams((int) LayoutParams.MATCH_PARENT, 2);
        params.addRule(RelativeLayout.RIGHT_OF, currencyId);
        params.addRule(RelativeLayout.LEFT_OF, id);
        params.setMargins(0, Util.convertDpToPxl(15, getApplicationContext()), 0, 0);
        if (i != 0) {
            params.addRule(RelativeLayout.BELOW, recent.getId());
        }
        viewPoint2.setLayoutParams(params);
        accLayout.addView(viewPoint2, params);

        TextView currentTextView = new TextView(getApplicationContext());
        currentTextView.setText(account.getLiquidity());
        currentTextView.setTextColor(Color.GRAY);
        currentTextView.setId(id);
        params = new RelativeLayout.LayoutParams((int) LayoutParams.WRAP_CONTENT,
                (int) LayoutParams.WRAP_CONTENT);
        if (i != 0) {
            params.addRule(RelativeLayout.BELOW, recent.getId());
        }
        params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        currentTextView.setLayoutParams(params);
        recent = currentTextView;
        accLayout.addView(currentTextView, params);
        textViews.add(currentTextView);

        id++;
        nameID++;
        viewId1++;
        currencyId++;
    }
    buildUi(false);
    // Set context
    EasyTracker.getInstance().setContext(getApplicationContext());
    // Instantiate the Tracker
    tracker = EasyTracker.getTracker();
}

From source file:at.alladin.rmbt.android.fragments.history.RMBTFilterFragment.java

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

    super.onCreateView(inflater, container, savedInstanceState);

    view = inflater.inflate(R.layout.history_filter, container, false);

    deviceListView = (LinearLayout) view.findViewById(R.id.deviceList);
    networkListView = (LinearLayout) view.findViewById(R.id.networkList);

    final RelativeLayout resultLimitView = (RelativeLayout) view.findViewById(R.id.Limit25Wrapper);
    limit25CheckBox = (CheckBox) view.findViewById(R.id.Limit25CheckBox);

    if (activity.getHistoryResultLimit() == 250)
        limit25CheckBox.setChecked(true);
    else//w w w  . j av a2 s  .c o  m
        limit25CheckBox.setChecked(false);

    resultLimitView.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(final View v) {
            if (limit25CheckBox.isChecked()) {
                limit25CheckBox.setChecked(false);
                activity.setHistoryResultLimit(0);
            } else {
                limit25CheckBox.setChecked(true);
                activity.setHistoryResultLimit(250);
            }

        }

    });

    devicesToShow = activity.getHistoryFilterDevicesFilter();
    networksToShow = activity.getHistoryFilterNetworksFilter();

    if (devicesToShow == null && networksToShow == null) {
        devicesToShow = new ArrayList<String>();
        networksToShow = new ArrayList<String>();
    }

    final float scale = activity.getResources().getDisplayMetrics().density;

    final int leftRightItem = Helperfunctions.dpToPx(5, scale);
    // int topBottomItem = Helperfunctions.dpToPx(5, scale);

    // int leftRightDiv = Helperfunctions.dpToPx(0, scale);
    // int topBottomDiv = Helperfunctions.dpToPx(0, scale);
    final int heightDiv = Helperfunctions.dpToPx(1, scale);

    // int topBottomImg = Helperfunctions.dpToPx(1, scale);

    final String historyDevices[] = activity.getHistoryFilterDevices();

    if (historyDevices != null) {

        for (int i = 0; i < historyDevices.length; i++) {

            final RelativeLayout singleItemLayout = new RelativeLayout(activity); // (LinearLayout)measurememtItemView.findViewById(R.id.measurement_item);

            singleItemLayout.setId(i);
            singleItemLayout.setClickable(true);
            singleItemLayout.setBackgroundResource(R.drawable.list_selector);

            singleItemLayout.setLayoutParams(
                    new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

            final TextView itemTitle = new TextView(activity, null, R.style.textMediumLight);

            RelativeLayout.LayoutParams layout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.MATCH_PARENT);
            layout.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
            layout.addRule(RelativeLayout.CENTER_VERTICAL);

            // itemTitle.setLayoutParams(layout);
            itemTitle.setGravity(Gravity.LEFT);
            itemTitle.setPadding(leftRightItem, 0, leftRightItem, 0);
            itemTitle.setText(historyDevices[i]);

            singleItemLayout.addView(itemTitle, layout);

            final CheckBox itemCheck = new CheckBox(activity);

            layout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
            layout.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
            layout.addRule(RelativeLayout.CENTER_VERTICAL);

            // itemCheck.setLayoutParams(layout);

            itemCheck.setGravity(Gravity.RIGHT);
            itemCheck.setPadding(leftRightItem, 0, leftRightItem, 0);
            itemCheck.setOnClickListener(null);
            itemCheck.setClickable(false);
            itemCheck.setId(i + historyDevices.length);

            if (devicesToShow.isEmpty() || devicesToShow.contains(historyDevices[i]))
                itemCheck.setChecked(true);
            else
                itemCheck.setChecked(false);

            singleItemLayout.addView(itemCheck, layout);

            // layout = new
            // RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
            // RelativeLayout.LayoutParams.WRAP_CONTENT);

            // singleItemLayout.setLayoutParams(layout);

            singleItemLayout.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(final View v) {
                    final CheckBox check = (CheckBox) v.findViewById(v.getId() + historyDevices.length);
                    if (check.isChecked()) {
                        check.setChecked(false);
                        devicesToShow.remove(historyDevices[v.getId()]);
                    } else {
                        check.setChecked(true);
                        devicesToShow.add(historyDevices[v.getId()]);
                    }

                }

            });

            deviceListView.addView(singleItemLayout);

            final View divider = new View(activity);

            layout = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, heightDiv);

            divider.setBackgroundResource(R.drawable.bg_trans_light_10);

            deviceListView.addView(divider, layout);

        }
        deviceListView.invalidate();
    }

    final String historyNetworks[] = activity.getHistoryFilterNetworks();

    if (historyNetworks != null) {

        for (int i = 0; i < historyNetworks.length; i++) {

            final RelativeLayout singleItemLayout = new RelativeLayout(activity); // (LinearLayout)measurememtItemView.findViewById(R.id.measurement_item);

            singleItemLayout.setId(i);
            singleItemLayout.setClickable(true);
            singleItemLayout.setBackgroundResource(R.drawable.list_selector);

            singleItemLayout.setLayoutParams(
                    new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

            final TextView itemTitle = new TextView(activity, null, R.style.textMediumLight);
            RelativeLayout.LayoutParams layout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.MATCH_PARENT);
            layout.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
            layout.addRule(RelativeLayout.CENTER_VERTICAL);

            // itemTitle.setLayoutParams(layout);
            itemTitle.setGravity(Gravity.LEFT);
            itemTitle.setPadding(leftRightItem, 0, leftRightItem, 0);
            itemTitle.setText(historyNetworks[i]);

            singleItemLayout.addView(itemTitle, layout);

            final CheckBox itemCheck = new CheckBox(activity);

            layout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
            layout.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
            layout.addRule(RelativeLayout.CENTER_VERTICAL);

            // itemCheck.setLayoutParams(layout);

            itemCheck.setGravity(Gravity.RIGHT);
            itemCheck.setPadding(leftRightItem, 0, leftRightItem, 0);
            itemCheck.setOnClickListener(null);
            itemCheck.setClickable(false);
            itemCheck.setId(i + historyNetworks.length);

            if (networksToShow.isEmpty() || networksToShow.contains(historyNetworks[i]))
                itemCheck.setChecked(true);
            else
                itemCheck.setChecked(false);

            singleItemLayout.addView(itemCheck, layout);

            singleItemLayout.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(final View v) {
                    final CheckBox check = (CheckBox) v.findViewById(v.getId() + historyNetworks.length);
                    if (check.isChecked()) {
                        check.setChecked(false);
                        networksToShow.remove(historyNetworks[v.getId()]);
                    } else {
                        check.setChecked(true);
                        networksToShow.add(historyNetworks[v.getId()]);
                    }
                    System.out.println(networksToShow.toString());
                }

            });

            networkListView.addView(singleItemLayout);

            final View divider = new View(activity);

            layout = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, heightDiv);

            divider.setBackgroundResource(R.drawable.bg_trans_light_10);

            networkListView.addView(divider, layout);

        }
        networkListView.invalidate();
    }
    /*
     * // Set option as Multiple Choice. So that user can able to select
     * more the one option from list deviceListView.setAdapter(new
     * ArrayAdapter<String>(activity,
     * android.R.layout.simple_list_item_multiple_choice, historyDevices));
     * deviceListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
     * 
     * for (int i = 0; i < historyDevices.length; i++) {
     * //deviceListView.setItemChecked(i, true); }
     * 
     * deviceListView.setOnItemClickListener(new OnItemClickListener() {
     * 
     * @Override public void onItemClick(AdapterView<?> l, View v, int
     * position, long id) {
     * 
     * }
     * 
     * });
     * 
     * 
     * // Set option as Multiple Choice. So that user can able to select
     * more the one option from list networkListView.setAdapter(new
     * ArrayAdapter<String>(activity,
     * android.R.layout.simple_list_item_multiple_choice, networkDevices));
     * networkListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
     * 
     * for (int i = 0; i < networkDevices.length; i++) {
     * networkListView.setItemChecked(i, true); }
     * 
     * SparseBooleanArray checked =
     * deviceListView.getCheckedItemPositions(); ArrayList<String>
     * devicesToShow = new ArrayList<String>(); for(int i = 0; i <
     * checked.size()+1; i++){ if(checked.get(i))
     * devicesToShow.add(historyDevices[i]); }
     */

    return view;
}

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

public void initialization(Bundle icicle, final boolean landscape, final boolean openAD, final LAD lad,
        final String publisherId, final String keywords, final int requestInterval) {
    LSystem.gc();// w  w  w.  ja  va  2s  .  co  m
    this.androidSelect = -2;
    frameLayout = new FrameLayout(LGameActivity.this);
    super.onCreate(icicle);
    if (openAD) {
        // setVolumeControlStream(AudioManager.STREAM_MUSIC);
        AdManager.setPublisherId(publisherId);
        AdManager.setTestDevices(new String[] { "" });
        AdManager.setAllowUseOfLocation(true);
        view = new LGameView(LGameActivity.this, landscape);
        adview = new AdView(LGameActivity.this);
        adview.setKeywords(keywords);
        adview.setRequestInterval(requestInterval);
        adview.setGravity(Gravity.NO_GRAVITY);
        RelativeLayout rl = new RelativeLayout(LGameActivity.this);
        RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
                LayoutParams.WRAP_CONTENT);
        if (lad == LAD.LEFT) {
            lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 1);
        } else if (lad == LAD.RIGHT) {
            lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 1);
        } else if (lad == LAD.TOP) {
            lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 1);
        } else {
            lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 1);
        }
        visible = true;
        adview.requestFreshAd();
        frameLayout.addView(view);
        rl.addView(adview, lp);
        frameLayout.addView(rl);
    } else {
        view = new LGameView(LGameActivity.this, landscape);
        frameLayout.addView(view);
    }
    if (view != null) {
        gameHandler = view.getGameHandler();
    }

}

From source file:com.morestudio.littledot.doctor.ui.messages.MessageAdapter.java

private void setPhotoSide(MessageListItemViews tagView, ArrowPosition pos) {
    LayoutParams lp = (LayoutParams) tagView.quickContactView.getLayoutParams();
    lp.addRule(// w w w  .j a v  a 2s  . c o  m
            (pos == ArrowPosition.LEFT) ? RelativeLayout.ALIGN_PARENT_RIGHT : RelativeLayout.ALIGN_PARENT_LEFT);
    lp.addRule(
            (pos == ArrowPosition.LEFT) ? RelativeLayout.ALIGN_PARENT_LEFT : RelativeLayout.ALIGN_PARENT_RIGHT,
            0);

    lp = (LayoutParams) tagView.containterBlock.getLayoutParams();
    lp.addRule((pos == ArrowPosition.LEFT) ? RelativeLayout.LEFT_OF : RelativeLayout.RIGHT_OF,
            R.id.quick_contact_photo);
    lp.addRule((pos == ArrowPosition.LEFT) ? RelativeLayout.RIGHT_OF : RelativeLayout.LEFT_OF, 0);
    tagView.quickContactView.setPosition(pos);

}

From source file:com.abcvoipsip.ui.messages.MessageAdapter.java

private void setPhotoSide(MessageListItemViews tagView, ArrowPosition pos) {
    LayoutParams lp = (RelativeLayout.LayoutParams) tagView.quickContactView.getLayoutParams();
    lp.addRule(/*  w  w  w .j  a v  a  2  s  .c o  m*/
            (pos == ArrowPosition.LEFT) ? RelativeLayout.ALIGN_PARENT_RIGHT : RelativeLayout.ALIGN_PARENT_LEFT);
    lp.addRule(
            (pos == ArrowPosition.LEFT) ? RelativeLayout.ALIGN_PARENT_LEFT : RelativeLayout.ALIGN_PARENT_RIGHT,
            0);

    lp = (RelativeLayout.LayoutParams) tagView.containterBlock.getLayoutParams();
    lp.addRule((pos == ArrowPosition.LEFT) ? RelativeLayout.LEFT_OF : RelativeLayout.RIGHT_OF,
            R.id.quick_contact_photo);
    lp.addRule((pos == ArrowPosition.LEFT) ? RelativeLayout.RIGHT_OF : RelativeLayout.LEFT_OF, 0);
    tagView.quickContactView.setPosition(pos);

}

From source file:com.noriginmedia.exoplayer.VideoPlayerFragment.java

private void resizeVideo(Configuration config, boolean fullscreen, int screenWidth, int screenHeight,
        boolean isPortrait, boolean softkeys) {
    if (mView == null || mPlayerView == null)
        return;/* ww w  .ja  va  2s . c  o m*/

    int displayWidth = screenWidth;
    int displayHeight = screenHeight;
    int videoWidth = 0;
    int videoHeight = 0;
    int left = 0;
    int top = 0;

    videoWidth = displayWidth;
    videoHeight = displayHeight;

    Log.d(LOG_TAG, "_-_ resizingVideo... vH:" + videoHeight + " vW:" + videoWidth + " mLastH:"
            + mLastVideoHeight + " mLastW:" + mLastVideoWidth);
    int vTop, vLeft;

    if (videoWidth > 0 && videoHeight > 0 && !fullscreen) {
        if (displayHeight - videoHeight > 0) {
            vTop = top + (displayHeight - videoHeight) / 2;
        } else {
            vTop = top;
        }

        if (displayWidth - videoWidth > 0) {
            vLeft = left + (displayWidth - videoWidth) / 2;
        } else {
            vLeft = left;
        }
    } else {
        vTop = 0;
        vLeft = 0;
    }

    if (mLastVideoWidth != videoWidth || mLastVideoHeight != videoHeight || vTop != mLastTop
            || vLeft != mLastLeft) {
        RelativeLayout.LayoutParams paramsV;

        if (videoWidth > 0 && videoHeight > 0) {
            paramsV = new RelativeLayout.LayoutParams(videoWidth, videoHeight);
            paramsV.addRule(RelativeLayout.ALIGN_PARENT_TOP);
            paramsV.addRule(RelativeLayout.ALIGN_PARENT_LEFT);

        } else {
            paramsV = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT,
                    RelativeLayout.LayoutParams.FILL_PARENT);
            paramsV.addRule(RelativeLayout.CENTER_IN_PARENT);
        }
        mLastTop = paramsV.topMargin = vTop;
        mLastLeft = paramsV.leftMargin = vLeft;
        Log.d(LOG_TAG, "_-_ resizedVideo tm:" + paramsV.topMargin + " tl: " + paramsV.leftMargin + " w:"
                + paramsV.width + " h:" + paramsV.height + " fullscreen:" + fullscreen);

        mPlayerView.setLayoutParams(paramsV);
        mView.requestLayout();

        mLastVideoHeight = videoHeight;
        mLastVideoWidth = videoWidth;
    }

    boolean fullView = (displayWidth >= screenWidth && displayHeight >= screenHeight);
}

From source file:com.github.yggie.pulltorefresh.PullListFragment.java

/**
 * Called to do initial creation of the fragment. Creates all the Views in code
 *
 * @param inflater The LayoutInflater/*from  w ww. j a v a  2 s .  c o m*/
 * @param container The parent container
 * @param savedInstanceState The saved pullState
 * @return The inflated view
 */

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = getActivity();

    // setup the list view
    listView = new CustomListView(this);
    listView.setId(ID_LIST_VIEW);
    final RelativeLayout.LayoutParams listViewParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    listViewParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    listViewParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    listView.setLayoutParams(listViewParams);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
            onListItemClick((ListView) adapterView, view, position, id);
        }
    });

    // setup the empty view
    final TextView textView = new TextView(context);
    textView.setLayoutParams(listViewParams);
    textView.setGravity(Gravity.CENTER);
    textView.setText("Nothing to show");
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18.0f);
    emptyView = textView;
    emptyView.setId(ID_EMPTY_VIEW);

    // setup top pulled view
    final RelativeLayout.LayoutParams topViewParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    topViewParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    topViewParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    final FrameLayout topFrameLayout = new FrameLayout(context);
    topFrameLayout.setLayoutParams(topViewParams);
    // setup the default child of the FrameLayout
    topManager = new DefaultPulledView(this, true);
    topFrameLayout.addView(topManager);
    topPulledView = topFrameLayout;
    topPulledView.setId(ID_TOP_VIEW);

    // setup bottom pulled view
    final RelativeLayout.LayoutParams bottomViewParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    bottomViewParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    bottomViewParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    final FrameLayout bottomFrameLayout = new FrameLayout(context);
    bottomFrameLayout.setLayoutParams(bottomViewParams);
    // setup the default child in the FrameLayout
    bottomManager = new DefaultPulledView(this, false);
    bottomFrameLayout.addView(bottomManager);
    bottomPulledView = bottomFrameLayout;
    bottomPulledView.setId(ID_BOTTOM_VIEW);

    layout = new PullToRefreshLayout(this);
    layout.addView(topPulledView);
    layout.addView(bottomPulledView);
    layout.addView(listView);
    layout.addView(emptyView);
    layout.setId(ID_LAYOUT);

    listShown = false;
    listView.setVisibility(View.GONE);
    emptyView.setVisibility(View.VISIBLE);

    // applies the XML attributes, if exists
    if (attrs != null) {
        final TypedArray a = getActivity().obtainStyledAttributes(attrs, R.styleable.PullListFragment);
        if (a != null) {
            parseXmlAttributes(a);
            a.recycle();
        }
        attrs = null;
    }

    return layout;
}

From source file:net.gaast.giggity.ScheduleViewActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    app = (Giggity) getApplication();/*from   www.j a v a2s  . c  o m*/

    pref = PreferenceManager.getDefaultSharedPreferences(app);
    curView = getResources()
            .getIdentifier(pref.getString("default_view", "net.gaast.giggity:id/block_schedule"), null, null);
    showHidden = pref.getBoolean("show_hidden", false);

    /* Consider making this a setting, some may find their tablet too small. */
    int screen = getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;
    tabletView = (screen >= Configuration.SCREENLAYOUT_SIZE_LARGE);

    setContentView(R.layout.schedule_view_activity);
    View dl = drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
    drawer = (RelativeLayout) dl.findViewById(R.id.drawer);

    drawer.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // NOOP at least for now just so touches don't fall through to bigScreen.
        }
    });

    ViewGroup menu = (LinearLayout) dl.findViewById(R.id.menu);
    menu.getChildCount();
    /* Set event handler for all static buttons, going to the option menu code. Dynamic buttons
     * (from the schedule) have their own handlers. */
    for (int i = 0; i < menu.getChildCount(); ++i) {
        View btn = menu.getChildAt(i);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // Not for now as I can't undo it (toggler not calling handlers?) TODO v.setBackground(getResources().getDrawable(R.drawable.menu_gradient));
                onOptionsItemSelectedInt(v.getId());
                drawerLayout.closeDrawers();
            }
        });
    }

    if (wantDrawer) {
        /* Hamburger menu! */
        /* Should still consider v7-appcompat, depending on how much it, again, affects apk size.. */
        getActionBar().setDisplayHomeAsUpEnabled(true);
        drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_menu_white_24dp,
                R.string.navdrawer_on, R.string.navdrawer_off) {
            @Override
            public void onDrawerOpened(View drawerView) {
                super.onDrawerOpened(drawerView);
                invalidateOptionsMenu();
                /* Looks like this code doesn't actually run BTW. Need to figure that out later. */
                updateNavDrawer();
            }

            @Override
            public void onDrawerClosed(View drawerView) {
                super.onDrawerClosed(drawerView);
                invalidateOptionsMenu();
            }
        };
    } else {
        drawerLayout.removeView(drawer);
    }

    bigScreen = (LinearLayout) dl.findViewById(R.id.bigScreen);
    updateOrientation(getResources().getConfiguration().orientation);

    viewerContainer = (RelativeLayout) dl.findViewById(R.id.viewerContainer);

    /* TODO: See if I can do this in XML as well? (It's a custom private view.) */
    RelativeLayout.LayoutParams lp;
    lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
            RelativeLayout.LayoutParams.WRAP_CONTENT);
    lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    days = new DayButtons(this);
    viewerContainer.addView(days, lp);

    redraw = false;
    timer = new Handler();

    /* If the OS informs us that the timezone changes, close this activity so the schedule
       gets reloaded. (This because input is usually TZ-unaware while our objects aren't.) */
    tzClose = new BroadcastReceiver() {
        @Override
        public void onReceive(Context arg0, Intent arg1) {
            ScheduleViewActivity.this.finish();
        }
    };
    registerReceiver(tzClose, new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED));

    if (!getIntent().getAction().equals(Intent.ACTION_VIEW))
        return;

    String url = getIntent().getDataString();
    Fetcher.Source fs;
    if (getIntent().getBooleanExtra("PREFER_CACHED", false))
        fs = Fetcher.Source.CACHE_ONLINE;
    else
        fs = Fetcher.Source.ONLINE_CACHE;

    /* I think reminders come in via this activity (instead of straight to itemview)
       because we may have to reload schedule data? */
    if (url.contains("#")) {
        String parts[] = url.split("#", 2);
        url = parts[0];
        showEventId = parts[1];
    }

    if (app.hasSchedule(url)) {
        try {
            sched = app.getSchedule(url, fs);
        } catch (Exception e) {
            // Java makes me tired.
            e.printStackTrace();
        }
        onScheduleLoaded();
    } else {
        loadScheduleAsync(url, fs);
    }
}