Java Code Examples for android.widget.RelativeLayout.LEFT_OF

The following are Jave code examples for showing how to use LEFT_OF of the android.widget.RelativeLayout class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: DateTimePicker   File: TimePickerClockDelegate.java   Source Code and License Vote up 5 votes
private void setAmPmAtStart(boolean isAmPmAtStart) {
    if (mIsAmPmAtStart != isAmPmAtStart) {
        mIsAmPmAtStart = isAmPmAtStart;

        final RelativeLayout.LayoutParams params =
                (RelativeLayout.LayoutParams) mAmPmLayout.getLayoutParams();

        /*if (params.getRule(RelativeLayout.RIGHT_OF) != 0 ||
                params.getRule(RelativeLayout.LEFT_OF) != 0) {
            if (isAmPmAtStart) {
                params.removeRule(RelativeLayout.RIGHT_OF);
                params.addRule(RelativeLayout.LEFT_OF, mHourView.getId());
            } else {
                params.removeRule(RelativeLayout.LEFT_OF);
                params.addRule(RelativeLayout.RIGHT_OF, mMinuteView.getId());
            }
        }*/
        int[] rules = params.getRules();

        if (rules[RelativeLayout.RIGHT_OF] != 0 ||
                rules[RelativeLayout.LEFT_OF] != 0) {
            if (isAmPmAtStart) {
                params.addRule(RelativeLayout.RIGHT_OF, 0);
                params.addRule(RelativeLayout.LEFT_OF, mHourView.getId());
            } else {
                params.addRule(RelativeLayout.LEFT_OF, 0);
                params.addRule(RelativeLayout.RIGHT_OF, mMinuteView.getId());
            }
        }

        mAmPmLayout.setLayoutParams(params);
    }
}