Example usage for android.widget RelativeLayout BELOW

List of usage examples for android.widget RelativeLayout BELOW

Introduction

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

Prototype

int BELOW

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

Click Source Link

Document

Rule that aligns a child's top edge with another child's bottom edge.

Usage

From source file:Main.java

public static RelativeLayout.LayoutParams getViewPositionParams(String alignment, int offsetX, int offsetY,
        int w, int h, int below) {

    // create a layout params
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(w, h);

    // alignment vertical rule
    if (alignment.contains("top")) {
        params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    } else if (alignment.contains("bottom")) {
        params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    } else {/* w  w w .j a v  a 2 s . c  o  m*/
        params.addRule(RelativeLayout.CENTER_VERTICAL);
    }

    // alignment horizontal rule
    if (alignment.contains("left")) {
        params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    } else if (alignment.contains("right")) {
        params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    } else {
        params.addRule(RelativeLayout.CENTER_HORIZONTAL);
    }

    // set below
    if (below > 0) {
        params.addRule(RelativeLayout.BELOW, below);
    }

    return params;
}

From source file:Main.java

public static void applyAttributes(JSONObject jsonObject, RelativeLayout.LayoutParams layoutParams)
        throws JSONException {

    applyRelativeLayoutRuleIfExists(jsonObject, layoutParams, TO_LEFT_OF, RelativeLayout.LEFT_OF);
    applyRelativeLayoutRuleIfExists(jsonObject, layoutParams, TO_RIGHT_OF, RelativeLayout.RIGHT_OF);
    applyRelativeLayoutRuleIfExists(jsonObject, layoutParams, BELOW, RelativeLayout.BELOW);
    applyRelativeLayoutRuleIfExists(jsonObject, layoutParams, ABOVE, RelativeLayout.ABOVE);
    applyRelativeLayoutRuleIfExists(jsonObject, layoutParams, ALIGN_LEFT, RelativeLayout.ALIGN_LEFT);
    applyRelativeLayoutRuleIfExists(jsonObject, layoutParams, ALIGN_RIGHT, RelativeLayout.ALIGN_RIGHT);
    applyRelativeLayoutRuleIfExists(jsonObject, layoutParams, ALIGN_TOP, RelativeLayout.ALIGN_TOP);

    applyRelativeLayoutBooleanIfExists(jsonObject, layoutParams, ALIGN_PARENT_TOP,
            RelativeLayout.ALIGN_PARENT_TOP);
    applyRelativeLayoutBooleanIfExists(jsonObject, layoutParams, ALIGN_PARENT_BOTTOM,
            RelativeLayout.ALIGN_PARENT_BOTTOM);
    applyRelativeLayoutBooleanIfExists(jsonObject, layoutParams, ALIGN_PARENT_RIGHT,
            RelativeLayout.ALIGN_PARENT_RIGHT);
    applyRelativeLayoutBooleanIfExists(jsonObject, layoutParams, ALIGN_PARENT_LEFT,
            RelativeLayout.ALIGN_PARENT_LEFT);
    applyRelativeLayoutBooleanIfExists(jsonObject, layoutParams, ALIGN_BASELINE, RelativeLayout.ALIGN_BASELINE);
    applyRelativeLayoutBooleanIfExists(jsonObject, layoutParams, ALIGN_PARENT_TOP,
            RelativeLayout.ALIGN_PARENT_TOP);
    applyRelativeLayoutBooleanIfExists(jsonObject, layoutParams, CENTER_HORIZONTAL,
            RelativeLayout.CENTER_HORIZONTAL);
    applyRelativeLayoutBooleanIfExists(jsonObject, layoutParams, CENTER_IN_PARENT,
            RelativeLayout.CENTER_IN_PARENT);
    applyRelativeLayoutBooleanIfExists(jsonObject, layoutParams, CENTER_VERTICAL,
            RelativeLayout.CENTER_VERTICAL);
}

From source file:com.binomed.showtime.android.util.CineShowTimeLayoutUtils.java

public static void manageVisibiltyFieldSpeech(Context context, ImageButton button, AutoCompleteTextView text,
        int idRightof, int idLeftOf, int idBelow) {
    // Manage speech button just if package present on device
    PackageManager pm = context.getPackageManager();
    List<ResolveInfo> activities = pm
            .queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);
    if (activities.size() == 0) {
        button.setVisibility(View.GONE);

        if ((text != null) && (Integer.valueOf(Build.VERSION.SDK) <= 3)) {
            // Manage specificity for version before 4
            RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
                    LayoutParams.WRAP_CONTENT);
            if (idRightof != -1) {
                params.addRule(RelativeLayout.RIGHT_OF, idRightof);
            }/* w  w w  .  j ava 2 s .c o  m*/
            if (idLeftOf != -1) {
                params.addRule(RelativeLayout.LEFT_OF, idLeftOf);
            }
            if (idBelow != -1) {
                params.addRule(RelativeLayout.BELOW, idBelow);
            }
            text.setSingleLine(true);
            text.setLayoutParams(params);
        }
    }
}

From source file:edu.rowan.app.fragments.HomescreenFragment.java

/**
 * Construct the view for this fragment.
 * The core layout of this fragment is a CarouselView and grid of available buttons
 *//* ww w  . ja  v  a 2 s.com*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // hide actionbar loading indicator TODO: move this elsewhere
    activity.showLoading(false);

    View view = inflater.inflate(R.layout.activity_main, container, false);
    RelativeLayout layout = (RelativeLayout) view.findViewById(R.id.mainLayout);
    layout.setPadding(0, 20, 0, 0);

    CarouselView rowanFeatures = new CarouselView(inflater.getContext());
    // set view Id so that relativeLayout can position. Without an Id relativeLayout doesn't work
    rowanFeatures.setId(2342343);
    layout.addView(rowanFeatures);
    setTouchListener(rowanFeatures);

    GridView grid = new GridView(inflater.getContext());
    grid.setOnItemClickListener(this);
    grid.setNumColumns(3);
    grid.setVerticalSpacing(20);
    grid.setAdapter(new RowanAdapter());
    RelativeLayout.LayoutParams gridParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT);
    gridParams.addRule(RelativeLayout.BELOW, rowanFeatures.getId());
    gridParams.topMargin = 20;
    layout.addView(grid, gridParams);

    return view;
}

From source file:com.normalexception.app.rx8club.fragment.utils.CompressionFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    MainApplication.setState(AppState.State.UTIL_COMPRESSION, this);

    RelativeLayout rl = (RelativeLayout) getView().findViewById(R.id.content_frame);

    v = getActivity().getLayoutInflater().inflate(R.layout.view_compression, rl);

    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);//from  ww w .  j av  a  2  s  .  com
    params.addRule(RelativeLayout.BELOW, R.id.mainlisttitle);

    ScrollView sv = new ScrollView(getActivity());
    sv.addView(v);
    sv.setLayoutParams(params);

    rl.addView(sv);

    ViewHolder.get(v, R.id.compressionNormalize).setOnClickListener(new CompressionListener());
}

From source file:de.geeksfactory.opacclient.frontend.AccountListActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_account_list);
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    fab = (FloatingActionButton) findViewById(R.id.add_fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override//from ww w .j av a  2  s .  c o m
        public void onClick(View v) {
            add();
        }
    });
    DisplayMetrics displayMetrics = getResources().getDisplayMetrics();

    float density = getResources().getDisplayMetrics().density;
    float dpWidth = displayMetrics.widthPixels / density;
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(Math.round(72 * density),
            Math.round(72 * density));

    if (dpWidth >= 864) {
        params.addRule(RelativeLayout.BELOW, R.id.toolbar);
        params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        params.setMargins(0, Math.round(-36 * density), Math.round(36 * density), 0);
        ViewCompat.setElevation(fab, 4 * density);
    } else {
        params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
        params.setMargins(0, 0, Math.round(36 * density), Math.round(36 * density));
        ViewCompat.setElevation(fab, 12 * density);
    }
    fab.setLayoutParams(params);
}

From source file:com.ab.activity.AbActivity.java

/**
 * ??./*w  w  w . j a  v  a  2 s.c o  m*/
 *
 * @param savedInstanceState the saved instance state
 * @see android.support.v4.app.FragmentActivity#onCreate(android.os.Bundle)
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    mInflater = LayoutInflater.from(this);

    //?
    mAbTitleBar = new AbTitleBar(this);

    //
    ab_base = new RelativeLayout(this);
    ab_base.setBackgroundColor(Color.rgb(255, 255, 255));

    //
    contentLayout = new RelativeLayout(this);
    contentLayout.setPadding(0, 0, 0, 0);

    //?
    mAbBottomBar = new AbBottomBar(this);

    //View
    ab_base.addView(mAbTitleBar,
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

    mAbTitleBar.setVisibility(View.GONE);

    RelativeLayout.LayoutParams layoutParamsBottomBar = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParamsBottomBar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    ab_base.addView(mAbBottomBar, layoutParamsBottomBar);

    RelativeLayout.LayoutParams layoutParamsContent = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParamsContent.addRule(RelativeLayout.BELOW, mAbTitleBar.getId());
    layoutParamsContent.addRule(RelativeLayout.ABOVE, mAbBottomBar.getId());
    ab_base.addView(contentLayout, layoutParamsContent);

    //Application?
    abApplication = getApplication();

    //ContentView
    setContentView(ab_base,
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
}

From source file:com.bangqu.eshow.activity.ESActivity.java

/**
 * ??./*  w  ww . ja  va 2  s . c  o  m*/
 *
 * @param savedInstanceState the saved instance state
 * @see android.support.v4.app.FragmentActivity#onCreate(android.os.Bundle)
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    mInflater = LayoutInflater.from(this);

    //?
    mAbTitleBar = new ESTitleBar(this);

    //
    ab_base = new RelativeLayout(this);
    ab_base.setBackgroundColor(Color.rgb(255, 255, 255));

    //
    contentLayout = new RelativeLayout(this);
    contentLayout.setPadding(0, 0, 0, 0);

    //?
    mAbBottomBar = new ESBottomBar(this);

    //View
    ab_base.addView(mAbTitleBar,
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

    mAbTitleBar.setVisibility(View.GONE);

    RelativeLayout.LayoutParams layoutParamsBottomBar = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParamsBottomBar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    ab_base.addView(mAbBottomBar, layoutParamsBottomBar);

    RelativeLayout.LayoutParams layoutParamsContent = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParamsContent.addRule(RelativeLayout.BELOW, mAbTitleBar.getId());
    layoutParamsContent.addRule(RelativeLayout.ABOVE, mAbBottomBar.getId());
    ab_base.addView(contentLayout, layoutParamsContent);

    //Application?
    abApplication = getApplication();

    //ContentView
    setContentView(ab_base,
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    ESActivityManager.getInstance().addActivity(this);
}

From source file:cn.org.eshow.framwork.activity.AbActivity.java

/**
 * ??.//from   w w  w .  j a  v a2  s.c  o m
 *
 * @param savedInstanceState the saved instance state
 * @see android.support.v4.app.FragmentActivity#onCreate(android.os.Bundle)
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    mInflater = LayoutInflater.from(this);

    //?
    mAbTitleBar = new AbTitleBar(this);

    //
    ab_base = new RelativeLayout(this);
    ab_base.setBackgroundColor(Color.rgb(255, 255, 255));

    //
    contentLayout = new RelativeLayout(this);
    contentLayout.setPadding(0, 0, 0, 0);

    //?
    mAbBottomBar = new AbBottomBar(this);

    //View
    ab_base.addView(mAbTitleBar,
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

    mAbTitleBar.setVisibility(View.GONE);

    RelativeLayout.LayoutParams layoutParamsBottomBar = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParamsBottomBar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    ab_base.addView(mAbBottomBar, layoutParamsBottomBar);

    RelativeLayout.LayoutParams layoutParamsContent = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParamsContent.addRule(RelativeLayout.BELOW, mAbTitleBar.getId());
    layoutParamsContent.addRule(RelativeLayout.ABOVE, mAbBottomBar.getId());
    ab_base.addView(contentLayout, layoutParamsContent);

    //Application?
    abApplication = getApplication();

    //ContentView
    setContentView(ab_base,
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    AbActivityManager.getInstance().addActivity(this);
}

From source file:nz.al4.airclock.AirClockFragment.java

private View setupDate() {
    // add digital date
    textDate = new TextClock(getContext());
    textDate.setId(textDateId);//from  w w  w  . j  a  v  a 2s.c o  m
    RelativeLayout.LayoutParams textDateParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    textDateParams.addRule(RelativeLayout.BELOW, textClockId);
    textDate.setLayoutParams(textDateParams);
    textDate.setTypeface(textDate.getTypeface(), Typeface.BOLD);
    textDate.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    textDate.setGravity(Gravity.CENTER_HORIZONTAL);

    SpannableString dateSpan = new SpannableString("yyyy/MM/dd");
    textDate.setFormat24Hour(dateSpan);
    textDate.setFormat12Hour(dateSpan);

    return textDate;
}