Example usage for android.widget RelativeLayout RelativeLayout

List of usage examples for android.widget RelativeLayout RelativeLayout

Introduction

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

Prototype

public RelativeLayout(Context context) 

Source Link

Usage

From source file:com.esri.arcgisruntime.sample.featurelayerupdateattributes.MainActivity.java

/**
 * Displays Callout//  w  w  w.  j a  va2  s.co  m
 * @param title the text to show in the Callout
 */
private void showCallout(String title) {

    // create a text view for the callout
    RelativeLayout calloutLayout = new RelativeLayout(getApplicationContext());

    TextView calloutContent = new TextView(getApplicationContext());
    calloutContent.setId(R.id.textview);
    calloutContent.setTextColor(Color.BLACK);
    calloutContent.setTextSize(18);
    calloutContent.setPadding(0, 10, 10, 0);

    calloutContent.setText(title);

    RelativeLayout.LayoutParams relativeParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    relativeParams.addRule(RelativeLayout.RIGHT_OF, calloutContent.getId());

    // create image view for the callout
    ImageView imageView = new ImageView(getApplicationContext());
    imageView.setImageDrawable(
            ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_info_outline_black_18dp));
    imageView.setLayoutParams(relativeParams);
    imageView.setOnClickListener(new ImageViewOnclickListener());

    calloutLayout.addView(calloutContent);
    calloutLayout.addView(imageView);

    mCallout.setLocation(mMapView.screenToLocation(mClickPoint));
    mCallout.setContent(calloutLayout);
    mCallout.show();
}

From source file:com.cranberrygame.phonegap.plugin.ad.Util.java

private void _preloadBannerAd() {
    if (bannerViewLayout == null) {
        bannerViewLayout = new RelativeLayout(cordova.getActivity());//   
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
        //webView.addView(bannerViewLayout, params);
        bannerViewLayout.setLayoutParams(params);
        webView.addView(bannerViewLayout);
    }/*from  ww w  . j a va2  s . c o  m*/

    if (bannerView != null) {
        bannerViewLayout.removeView(bannerView);
    }

    //if (bannerView==null) {
    //
    bannerView = new AdView(cordova.getActivity());//         
    bannerView.setAdUnitId(this.adUnit);
    bannerView.setAdListener(new MyBannerViewListener(bannerView));

    //https://developers.google.com/mobile-ads-sdk/docs/admob/android/banner
    if (size == null) {
        size = "SMART_BANNER";
    }
    if (size.equals("BANNER")) {
        bannerView.setAdSize(AdSize.BANNER);//Banner (320x50, Phones and Tablets)
    } else if (size.equals("LARGE_BANNER")) {
        bannerView.setAdSize(AdSize.LARGE_BANNER);//Large banner (320x100, Phones and Tablets)
    } else if (size.equals("MEDIUM_RECTANGLE")) {
        bannerView.setAdSize(AdSize.MEDIUM_RECTANGLE);//Medium rectangle (300x250, Phones and Tablets)
    } else if (size.equals("FULL_BANNER")) {
        bannerView.setAdSize(AdSize.FULL_BANNER);//Full banner (468x60, Tablets)
    } else if (size.equals("LEADERBOARD")) {
        bannerView.setAdSize(AdSize.LEADERBOARD);//Leaderboard (728x90, Tablets)
    } else if (size.equals("SMART_BANNER")) {
        bannerView.setAdSize(AdSize.SMART_BANNER);//Smart banner (Auto size, Phones and Tablets) //https://developers.google.com/mobile-ads-sdk/docs/admob/android/banner#smart
    } else {
        bannerView.setAdSize(AdSize.SMART_BANNER);
    }
    //}

    _refreshBannerAd();
}

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

protected void addBannerViewOverlap(String position, String size) {
    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);
        //plugin.getWebView().addView(bannerViewLayout, params);
        //plugin.getWebView().addView(bannerViewLayout);//only for ~cordova4
        //((ViewGroup)plugin.getWebView().getRootView()).addView(bannerViewLayout);//only for ~cordova4
        //((ViewGroup)plugin.getWebView().getView()).addView(bannerViewLayout);//only for cordova5~
        ((ViewGroup) getView(plugin.getWebView())).addView(bannerViewLayout);
    }//from  ww w  .  j a  va 2 s  .c  om

    //http://tigerwoods.tistory.com/11
    //http://developer.android.com/reference/android/widget/RelativeLayout.html
    //http://stackoverflow.com/questions/24900725/admob-banner-poitioning-in-android-on-bottom-of-the-screen-using-no-xml-relative
    RelativeLayout.LayoutParams 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);
    }

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

From source file:com.lifehackinnovations.siteaudit.FloorPlanActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    try {//from  ww  w .  jav  a  2  s  .c  om
        Tabs1.db.showfulldblog(Tabs1.db.TABLE_MCR_METERINGLIST);
    } catch (Throwable e) {

    }
    ctx = this;

    try {
        if (Tabs1.foldername.contains("_")) {
            tempfoldername = Tabs1.foldername.substring(0, Tabs1.foldername.indexOf("_"));
        } else {
            tempfoldername = Tabs1.foldername;
        }

        Log.d("foldername", tempfoldername);

        dbtablename = "floorplan";
        if (Tabs1.db.checktableindb(dbtablename)) {
            //
        } else {
            try {
                Tabs1.db.createfloorplandb(dbtablename);
            } catch (Throwable e) {
                e.printStackTrace();
            }
        }

        try {
            MULTILEVEL = ReadBoolean(this, "multilevel", false);
        } catch (Throwable e) {
            System.out.println("couldn't read multilevel value from preferences on start");
            MULTILEVEL = false;
        }

        try {
            NGBICONS = ReadBoolean(this, "ngbicons", false);
        } catch (Throwable e) {
            System.out.println("couldn't read autorenumber temp sensors value from preferences on start");
            NGBICONS = true;
        }

        try {
            DRAWSAMREFERENCE = ReadBoolean(this, "drawsamreferencetable", true);
        } catch (Throwable e) {

        }
        try {
            RAPIDPLACEMENT = ReadBoolean(this, "rapidplacement", false);
        } catch (Throwable e) {

        }

        // Remove title bar
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);

        // Remove notification bar
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);

        Intent intent = getIntent();

        FloorPlanActivity.floorplannumber = intent.getExtras().getInt("floorplannumber");
        try {
            FloorPlanActivity.floorplancount = Tabs1.FloorPlanCount;
        } catch (Throwable e) {
            FloorPlanActivity.floorplancount = new File(Tabs1.inputfloorplandirectory).list().length;
        }
        MODE = MODE_DONOTHING;

        progressDialog = new ProgressDialog(this);
        progressDialog.setIndeterminate(true);
        if (tempfoldername.equals("Paul")) {
            progressDialog.setIndeterminateDrawable(getResources().getDrawable(R.anim.paul_animation));

        } else if (tempfoldername.equals("Will")) {
            progressDialog.setIndeterminateDrawable(getResources().getDrawable(R.anim.will_animation));

        } else if (tempfoldername.equals("Bill")) {
            progressDialog.setIndeterminateDrawable(getResources().getDrawable(R.anim.bill_animation));
        } else {
            progressDialog.setIndeterminateDrawable(
                    getResources().getDrawable(R.anim.progress_dialog_icon_drawable_animation));

        }

        progressDialog.setIcon(R.drawable.ic_launcher);
        progressDialog.setTitle("Loading");
        progressDialog.setMessage("Please Wait");
        progressDialog.setCancelable(false);

        rl = new RelativeLayout(this);
        RelativeLayout.LayoutParams rllp = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
        rl.setLayoutParams(rllp);

        toolbar = new View(this);
        LayoutInflater inflater = (LayoutInflater) getBaseContext()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        toolbar = inflater.inflate(R.layout.toolbar, null);

        toptoolbar = (View) toolbar.findViewById(R.id.toptoolbar);
        righttoolbar = (View) toolbar.findViewById(R.id.righttoolbar);
        righttoolbarbuttonparent = (View) toolbar.findViewById(R.id.righttoolbarbuttonparent);

        righttoolbarscrollview = (ScrollView) toolbar.findViewById(R.id.righttoolbarscrollview);

        floorplanprevious = (ImageView) toolbar.findViewById(R.id.floorplanprevious);
        floorplannext = (ImageView) toolbar.findViewById(R.id.floorplannext);
        fullscreen = (ImageView) toolbar.findViewById(R.id.fullscreen);
        unfullscreen = (ImageView) toolbar.findViewById(R.id.unfullscreen);
        showlayers = (ImageView) toolbar.findViewById(R.id.layers);
        resizeicons = (ImageView) toolbar.findViewById(R.id.resizeicons);
        metersperpixelbutton = (ImageView) toolbar.findViewById(R.id.metersperpixelbutton);

        resizeiconsseekbar = (SeekBar) toolbar.findViewById(R.id.resizeiconsseekbar);
        resizeiconsseekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                // TODO Auto-generated method stub
                view.invalidate();
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                // TODO Auto-generated method stub

            }
        });

        resizeiconscancel = (Button) toolbar.findViewById(R.id.resizeiconscancel);
        resizeiconsfinished = (Button) toolbar.findViewById(R.id.resizeiconsfinished);

        preferences = (ImageView) toolbar.findViewById(R.id.preferences);

        floorplantitle = (TextView) toolbar.findViewById(R.id.floorplantitle);
        BMS = (ImageView) toolbar.findViewById(R.id.bms);
        ELC = (ImageView) toolbar.findViewById(R.id.elc);
        Gateway = (ImageView) toolbar.findViewById(R.id.gateway);
        SAM = (ImageView) toolbar.findViewById(R.id.sam);
        tempsensor = (ImageView) toolbar.findViewById(R.id.tempsensor);
        ethernetport = (ImageView) toolbar.findViewById(R.id.ethernetport);
        distributionboard = (ImageView) toolbar.findViewById(R.id.distributionboard);
        samarray = (ImageView) toolbar.findViewById(R.id.samarray);
        datahub = (ImageView) toolbar.findViewById(R.id.datahub);

        AddText = (ImageView) toolbar.findViewById(R.id.addtexttofloorplan);

        legend = (ImageView) toolbar.findViewById(R.id.legend);

        hiddenaddpicturebutton = new Button(this);
        hiddenaddpicturebutton.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {

                int tabforpicture = view.gettabofitemselected(view.itemselectednumber);
                String foldername = view.getGenericDisplayText(view.itemselectednumber);

                //   System.out.println("this is the name of the new file to be saved."+imageF.getAbsolutePath());
                //takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
                //      Uri.fromFile(imageF));

                Intent takePictureIntent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
                u.log("starting activity camera");

                PICTURESTARTTIME = System.currentTimeMillis();
                TABFORGETPICTURE = tabforpicture;
                FOLDERNAMEFORGETPICTURE = foldername;

                startActivityForResult(takePictureIntent, FLOORPLANGETPICFROMCAMERA);

            }
        });
        hiddeneditpicturebutton = new Button(this);
        hiddeneditpicturebutton.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {

                Intent intent = u.openpicture(editpicturelocation);
                System.out.println("this is the name of the file to be edited." + editpicturelocation);
                startActivityForResult(intent, EDITPICTUREACTIVITY);

            }
        });
        floorplantitle.setTextColor(view.presentableblue);
        floorplantitle.setText(Tabs1.floorplanname);

        floorplanprevious.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                ACTION = ACTION_FLOORPLANPREVIOUS;
                view.invalidate();
            }
        });
        floorplannext.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                ACTION = ACTION_FLOORPLANNEXT;
                view.invalidate();
            }
        });
        fullscreen.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {

                ACTION = ACTION_FULLSCREEN;
                toptoolbar.setVisibility(View.INVISIBLE);
                righttoolbar.setVisibility(View.INVISIBLE);
                unfullscreen.setVisibility(View.VISIBLE);

            }
        });

        unfullscreen.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                ACTION = ACTION_UNFULLSCREEN;
                toptoolbar.setVisibility(View.VISIBLE);
                righttoolbar.setVisibility(View.VISIBLE);
                unfullscreen.setVisibility(View.INVISIBLE);

            }
        });
        showlayers.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                Log.d("show layers selected", "true");
                if (!(ACTION == ACTION_SHOWLAYERS)) {
                    ACTION = ACTION_SHOWLAYERS;
                } else {
                    ACTION = ACTION_DONOTHING;
                }
                view.invalidate();

            }
        });
        metersperpixelbutton.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                //show dialog asking if you want scale from google maps, or from 2 points on map
                getscaledialog();
                //startActivity(u.intent("Getscalefromgooglemaps"));

            }
        });

        resizeicons.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                view.resizeboolean = true;
                ACTION = ACTION_RESIZEICONS;
                toptoolbar.setVisibility(View.INVISIBLE);
                righttoolbar.setVisibility(View.INVISIBLE);

                resizeiconsseekbar.setVisibility(View.VISIBLE);
                resizeiconscancel.setVisibility(View.VISIBLE);
                resizeiconsfinished.setVisibility(View.VISIBLE);

            }
        });
        resizeiconscancel.setOnClickListener(new Button.OnClickListener() {
            public void onClick(View arg0) {
                //restore size
                //resizeiconsseekbar.setProgress((int)((float)resizeiconsseekbar.getMax()/(float)4));
                view.invalidate();
                ACTION = ACTION_DONOTHING;
                toptoolbar.setVisibility(View.VISIBLE);
                righttoolbar.setVisibility(View.VISIBLE);

                resizeiconsseekbar.setVisibility(View.INVISIBLE);
                resizeiconscancel.setVisibility(View.INVISIBLE);
                resizeiconsfinished.setVisibility(View.INVISIBLE);

            }
        });
        resizeiconsfinished.setOnClickListener(new Button.OnClickListener() {
            public void onClick(View arg0) {
                if (ACTION == ACTION_RESIZEICON) {
                    writeonedbitem(view.itemselectednumber);
                } else {
                    rewritewholedb();
                }

                ACTION = ACTION_DONOTHING;
                toptoolbar.setVisibility(View.VISIBLE);
                righttoolbar.setVisibility(View.VISIBLE);

                resizeiconsseekbar.setVisibility(View.INVISIBLE);
                resizeiconscancel.setVisibility(View.INVISIBLE);
                resizeiconsfinished.setVisibility(View.INVISIBLE);

            }
        });

        preferences.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                ACTION = ACTION_PREFERENCES;
                //preferences();
                startActivityForResult(u.intent("FloorPlanPrefs"), PREFS);
            }
        });

        BMS.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                highlightbutton(arg0);
                MODE = MODE_BMS;
                Log.d("mode", u.s(MODE));

            }
        });
        ELC.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                highlightbutton(arg0);
                MODE = MODE_ELC;
                Log.d("mode", u.s(MODE));

            }
        });
        Gateway.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                highlightbutton(arg0);
                MODE = MODE_GATEWAY;
                Log.d("mode", u.s(MODE));

            }
        });
        SAM.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                highlightbutton(arg0);
                //MODE = MODE_SAM;
                //Log.d("mode", u.s(MODE));
                int itemnum = -1;
                for (int k = 0; k < view.i; k++) {
                    if (view.ITEMtype[k] == view.TYPE_ELC) {
                        itemnum = k;
                    }
                }
                if (!(itemnum == -1)) {
                    view.addsamsdialog("ELC# " + u.s(view.ELCdisplaynumber[itemnum]) + ": SAMs Menu", itemnum);
                }

            }
        });
        tempsensor.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                highlightbutton(arg0);
                MODE = MODE_TEMPSENSOR;
                Log.d("mode", u.s(MODE));

            }
        });
        ethernetport.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                highlightbutton(arg0);
                MODE = MODE_ETHERNETPORT;
                Log.d("mode", u.s(MODE));

            }
        });
        distributionboard.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                highlightbutton(arg0);
                MODE = MODE_DISTRIBUTIONBOARD;
                Log.d("mode", u.s(MODE));

            }
        });
        samarray.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                highlightbutton(arg0);
                MODE = MODE_SAMARRAY;
                Log.d("mode", u.s(MODE));

            }
        });
        datahub.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                highlightbutton(arg0);
                MODE = MODE_DATAHUB;
                Log.d("mode", u.s(MODE));

            }
        });

        AddText.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                highlightbutton(arg0);
                MODE = MODE_ADDTEXT;
                getaddtextdialog("ADD TEXT", view.i, FloorPlanActivity.this).show();
                Log.d("mode", u.s(MODE));

            }
        });

        legend.setOnClickListener(new ImageView.OnClickListener() {
            public void onClick(View arg0) {
                highlightbutton(arg0);
                MODE = MODE_LEGEND;
                Log.d("mode", u.s(MODE));

            }
        });

        view = new FloorPlanView(this);
        view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));

        rl.addView(view);
        rl.addView(toolbar);

        setContentView(rl);
        //readexcel();

        AUTORENUMBERTEMPS = !Tabs1.db.tableexists(dbtablename);

        WriteBoolean(this, "autorenumbertemps", AUTORENUMBERTEMPS);
        System.out.println("auto number=" + AUTORENUMBERTEMPS);

        readdb();
        grabsamcounts();
        grabelccount();
        System.out.println("item" + " " + "type" + "  " + "tempcount");
        for (int h = 0; h < view.i; h++) {
            System.out.println(h + " " + view.ITEMtype[h] + "  " + view.ITEMtempsensorcount[h]);
        }
    } catch (Throwable e) {
        e.printStackTrace();
        finish();
    }
}

From source file:fr.cph.chicago.core.adapter.NearbyAdapter.java

private View handleBuses(final int position, @NonNull final ViewGroup parent) {
    final LayoutInflater vi = (LayoutInflater) parent.getContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final View convertView = vi.inflate(R.layout.list_nearby, parent, false);

    // Bus/*ww w.  j  a v  a2s.co  m*/
    final int index = position - stations.size();
    final BusStop busStop = busStops.get(index);

    final ImageView imageView = (ImageView) convertView.findViewById(R.id.icon);
    imageView.setImageDrawable(
            ContextCompat.getDrawable(parent.getContext(), R.drawable.ic_directions_bus_white_24dp));

    final TextView routeView = (TextView) convertView.findViewById(R.id.station_name);
    routeView.setText(busStop.getName());

    final LinearLayout resultLayout = (LinearLayout) convertView.findViewById(R.id.nearby_results);

    final Map<String, List<BusArrival>> arrivalsForStop = busArrivals.get(busStop.getId(), new HashMap<>());

    Stream.of(arrivalsForStop.entrySet()).forEach(entry -> {
        final LinearLayout.LayoutParams leftParam = new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        final RelativeLayout insideLayout = new RelativeLayout(context);
        insideLayout.setLayoutParams(leftParam);
        insideLayout.setPadding(line1PaddingColor * 2, stopsPaddingTop, 0, 0);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            insideLayout.setBackground(ContextCompat.getDrawable(parent.getContext(), R.drawable.any_selector));
        }

        final RelativeLayout lineIndication = LayoutUtil.createColoredRoundForFavorites(context, TrainLine.NA);
        int lineId = Util.generateViewId();
        lineIndication.setId(lineId);

        final RelativeLayout.LayoutParams stopParam = new RelativeLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        stopParam.addRule(RelativeLayout.RIGHT_OF, lineId);
        stopParam.setMargins(Util.convertDpToPixel(context, 10), 0, 0, 0);

        final LinearLayout stopLayout = new LinearLayout(context);
        stopLayout.setOrientation(LinearLayout.VERTICAL);
        stopLayout.setLayoutParams(stopParam);
        int stopId = Util.generateViewId();
        stopLayout.setId(stopId);

        final RelativeLayout.LayoutParams boundParam = new RelativeLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        boundParam.addRule(RelativeLayout.RIGHT_OF, stopId);

        final LinearLayout boundLayout = new LinearLayout(context);
        boundLayout.setOrientation(LinearLayout.HORIZONTAL);

        final String direction = entry.getKey();
        final List<BusArrival> busArrivals = entry.getValue();
        final String routeId = busArrivals.get(0).getRouteId();

        final TextView bound = new TextView(context);
        final String routeIdText = routeId + " (" + direction + "): ";
        bound.setText(routeIdText);
        bound.setTextColor(ContextCompat.getColor(context, R.color.grey_5));
        boundLayout.addView(bound);

        Stream.of(busArrivals).forEach(busArrival -> {
            final TextView timeView = new TextView(context);
            final String timeLeftDueDelay = busArrival.getTimeLeftDueDelay() + " ";
            timeView.setText(timeLeftDueDelay);
            timeView.setTextColor(ContextCompat.getColor(context, R.color.grey));
            timeView.setLines(1);
            timeView.setEllipsize(TruncateAt.END);
            boundLayout.addView(timeView);
        });

        stopLayout.addView(boundLayout);

        insideLayout.addView(lineIndication);
        insideLayout.addView(stopLayout);
        resultLayout.addView(insideLayout);
    });

    convertView.setOnClickListener(new NearbyOnClickListener(googleMap, markers, busStop.getId(),
            busStop.getPosition().getLatitude(), busStop.getPosition().getLongitude()));
    return convertView;
}

From source file:org.protocoderrunner.apprunner.AppRunnerFragment.java

public RelativeLayout initLayout() {
    LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

    // add main layout
    mainLayout = new RelativeLayout(mActivity);
    mainLayout.setLayoutParams(layoutParams);
    mainLayout.setGravity(Gravity.BOTTOM);
    // mainLayout.setBackgroundColor(getResources().getColor(R.color.transparent));
    mainLayout.setBackgroundColor(getResources().getColor(R.color.white));

    // set the parent
    parentScriptedLayout = new RelativeLayout(mActivity);
    parentScriptedLayout.setLayoutParams(layoutParams);
    parentScriptedLayout.setGravity(Gravity.BOTTOM);
    parentScriptedLayout.setBackgroundColor(getResources().getColor(R.color.transparent));
    mainLayout.addView(parentScriptedLayout);

    // editor layout
    editorLayout = new FrameLayout(mActivity);
    FrameLayout.LayoutParams editorParams = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT);/*from w  ww.  j a  va 2  s .c  om*/
    editorLayout.setLayoutParams(editorParams);
    editorLayout.setId(EDITOR_ID);
    mainLayout.addView(editorLayout);

    // console layout
    consoleRLayout = new RelativeLayout(mActivity);
    RelativeLayout.LayoutParams consoleLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            getResources().getDimensionPixelSize(R.dimen.apprunner_console));
    consoleLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    consoleLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    consoleRLayout.setLayoutParams(consoleLayoutParams);
    consoleRLayout.setGravity(Gravity.BOTTOM);
    consoleRLayout.setBackgroundColor(getResources().getColor(R.color.blacktransparent));
    consoleRLayout.setVisibility(View.GONE);
    mainLayout.addView(consoleRLayout);

    // Create the text view to add to the console layout
    consoleText = new TextView(mActivity);
    LayoutParams consoleTextParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    consoleText.setBackgroundColor(getResources().getColor(R.color.transparent));
    consoleText.setTextColor(getResources().getColor(R.color.white));
    consoleText.setLayoutParams(consoleTextParams);
    int textPadding = getResources().getDimensionPixelSize(R.dimen.apprunner_console_text_padding);
    consoleText.setPadding(textPadding, textPadding, textPadding, textPadding);
    consoleRLayout.addView(consoleText);

    //add a close button
    Button closeBtn = new Button(mActivity);
    closeBtn.setText("x");
    closeBtn.setPadding(5, 5, 5, 5);
    closeBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showConsole(false);
        }
    });
    RelativeLayout.LayoutParams closeBtnLayoutParams = new RelativeLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    closeBtnLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    closeBtnLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    closeBtn.setLayoutParams(closeBtnLayoutParams);
    consoleRLayout.addView(closeBtn);

    liveCoding = new PLiveCodingFeedback(mActivity);
    mainLayout.addView(liveCoding.add());

    return mainLayout;
}

From source file:info.semanticsoftware.semassist.android.activity.SemanticAssistantsActivity.java

/** Presents additional information about a specific assistant.
 * @return a dynamically generated linear layout
 *///from   w w  w .j a  va 2s .  c  o  m
private LinearLayout getServiceDescLayout() {
    final LinearLayout output = new LinearLayout(this);
    final RelativeLayout topButtonsLayout = new RelativeLayout(this);
    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

    final Button btnBack = new Button(this);
    btnBack.setText(R.string.btnAllServices);
    btnBack.setId(5);
    btnBack.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            output.setVisibility(View.GONE);
            getListView().setVisibility(View.VISIBLE);
            lblAvAssist.setVisibility(View.VISIBLE);
        }
    });

    topButtonsLayout.addView(btnBack);

    final Button btnInvoke = new Button(this);
    btnInvoke.setText(R.string.btnInvokeLabel);
    btnInvoke.setId(6);

    btnInvoke.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            new InvocationTask().execute();
        }
    });

    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, btnInvoke.getId());
    btnInvoke.setLayoutParams(layoutParams);
    topButtonsLayout.addView(btnInvoke);

    output.addView(topButtonsLayout);

    TableLayout serviceInfoTbl = new TableLayout(this);
    output.addView(serviceInfoTbl);

    serviceInfoTbl.setColumnShrinkable(1, true);

    /* FIRST ROW */
    TableRow rowServiceName = new TableRow(this);

    TextView lblServiceName = new TextView(this);
    lblServiceName.setText(R.string.lblServiceName);
    lblServiceName.setTextAppearance(getApplicationContext(), R.style.titleText);

    TextView txtServiceName = new TextView(this);
    txtServiceName.setText(selectedService);
    txtServiceName.setTextAppearance(getApplicationContext(), R.style.normalText);
    txtServiceName.setPadding(10, 0, 0, 0);

    rowServiceName.addView(lblServiceName);
    rowServiceName.addView(txtServiceName);

    /* SECOND ROW */
    TableRow rowServiceDesc = new TableRow(this);

    TextView lblServiceDesc = new TextView(this);
    lblServiceDesc.setText(R.string.lblServiceDesc);
    lblServiceDesc.setTextAppearance(getApplicationContext(), R.style.titleText);

    TextView txtServiceDesc = new TextView(this);
    txtServiceDesc.setTextAppearance(getApplicationContext(), R.style.normalText);
    txtServiceDesc.setPadding(10, 0, 0, 0);
    List<GateRuntimeParameter> params = null;
    ServiceInfoForClientArray list = getServices();
    for (int i = 0; i < list.getItem().size(); i++) {
        if (list.getItem().get(i).getServiceName().equals(selectedService)) {
            txtServiceDesc.setText(list.getItem().get(i).getServiceDescription());
            params = list.getItem().get(i).getParams();
            break;
        }
    }

    TextView lblParams = new TextView(this);
    lblParams.setText(R.string.lblServiceParams);
    lblParams.setTextAppearance(getApplicationContext(), R.style.titleText);
    output.addView(lblParams);

    LayoutParams txtParamsAttrbs = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
    LinearLayout paramsLayout = new LinearLayout(this);
    paramsLayout.setId(0);

    if (params.size() > 0) {
        ScrollView scroll = new ScrollView(this);
        scroll.setLayoutParams(txtParamsAttrbs);
        paramsLayout.setOrientation(LinearLayout.VERTICAL);
        scroll.addView(paramsLayout);
        for (int j = 0; j < params.size(); j++) {
            TextView lblParamName = new TextView(this);
            lblParamName.setText(params.get(j).getParamName());
            EditText tview = new EditText(this);
            tview.setId(1);
            tview.setText(params.get(j).getDefaultValueString());
            LayoutParams txtViewLayoutParams = new LayoutParams(LayoutParams.FILL_PARENT,
                    LayoutParams.WRAP_CONTENT);
            tview.setLayoutParams(txtViewLayoutParams);
            paramsLayout.addView(lblParamName);
            paramsLayout.addView(tview);
        }
        output.addView(scroll);
    } else {
        TextView lblParamName = new TextView(this);
        lblParamName.setText(R.string.lblRTParams);
        output.addView(lblParamName);
    }

    rowServiceDesc.addView(lblServiceDesc);
    rowServiceDesc.addView(txtServiceDesc);

    serviceInfoTbl.addView(rowServiceName);
    serviceInfoTbl.addView(rowServiceDesc);

    output.setOrientation(LinearLayout.VERTICAL);
    output.setGravity(Gravity.TOP);

    return output;
}

From source file:me.piebridge.prevent.ui.UserGuideActivity.java

private void showDonateDialog() {
    RelativeLayout layout = new RelativeLayout(this);
    int pixel = getPixel(0x30);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(pixel, pixel);
    params.addRule(RelativeLayout.CENTER_IN_PARENT);
    layout.addView(new ProgressBar(this), params);
    donateDialog = ProgressDialog.show(this, null, null);
    donateDialog.setContentView(layout);
    donateDialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, pixel * 0x4);
}

From source file:com.raspi.chatapp.ui.chatting.SendImageFragment.java

/**
 * this function will initialize the ui showing the current image and reload
 * everything to make sure it is shown correctly
 *///from   w ww  . j  a  va2s . co m
private void initUI() {
    // set the actionBar title and subtitle
    if (actionBar != null) {
        actionBar.setTitle(R.string.send_image);
        actionBar.setSubtitle(name);
        //      actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor
        //              (R.color.action_bar_transparent)));
        //      // set the statusBar color
        //      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        //        getActivity().getWindow().setStatusBarColor(getResources().getColor(R
        //                .color.action_bar_transparent));
    }

    // instantiate the ViewPager
    viewPager = (ViewPager) getActivity().findViewById(R.id.send_image_view_pager);
    viewPager.setAdapter(new MyPagerAdapter());
    viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int position) {
            changePage(position, false, false);
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });

    //Cancel button pressed
    getView().findViewById(R.id.send_image_cancel).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // just return to the chatFragment
            mListener.onReturnClick();
        }
    });
    //Send button pressed
    getView().findViewById(R.id.send_image_send).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // create the progressDialog that is to be shown while saving
            // the image
            ProgressDialog progressDialog = new ProgressDialog(getContext());
            if (images.size() > 1)
                progressDialog.setTitle(
                        String.format(getResources().getString(R.string.sending_images), images.size()));
            else
                progressDialog.setTitle(R.string.sending_image);
            // run the sendImage in a new thread because I am saving the
            // image and this should be done in a new thread
            new Thread(new SendImagesRunnable(new Handler(), getContext(), progressDialog)).start();
        }
    });

    // generate the overview only if there are at least 2 images
    if (images.size() > 1) {
        // the layoutParams for the imageView which has the following attributes:
        // width = height = 65dp
        // margin = 5dp
        getActivity().findViewById(R.id.send_image_overview).setVisibility(View.VISIBLE);
        int a = Constants.dipToPixel(getContext(), 65);
        RelativeLayout.LayoutParams imageViewParams = new RelativeLayout.LayoutParams(a, a);
        int b = Constants.dipToPixel(getContext(), 5);
        imageViewParams.setMargins(b, b, b, b);
        // the layoutParams for the backgroundView which has the following
        // attributes:
        // width = height = 71dp
        // margin = 2dp
        int c = Constants.dipToPixel(getContext(), 71);
        RelativeLayout.LayoutParams backgroundParams = new RelativeLayout.LayoutParams(c, c);
        int d = Constants.dipToPixel(getContext(), 2);
        backgroundParams.setMargins(d, d, d, d);
        // the layoutParams for the relativeLayout containing the image and
        // the background which has the following attributes:
        // width = height = wrap_content
        LinearLayout.LayoutParams relativeLayoutParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        LinearLayout linearLayout = (LinearLayout) getActivity().findViewById(R.id.send_image_overview_content);
        linearLayout.removeAllViewsInLayout();
        int i = 0;
        for (Message msg : images) {
            // set up the imageView
            ImageView imageView = new ImageView(getContext());
            imageView.setLayoutParams(imageViewParams);
            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
            // load the bitmap async
            AsyncDrawable.BitmapWorkerTask bitmapWorker = new AsyncDrawable.BitmapWorkerTask(imageView, a, a,
                    true);
            imageView.setImageDrawable(new AsyncDrawable(getResources(), null, bitmapWorker));
            imageView.setOnClickListener(new overviewSelectListener(i++));
            bitmapWorker.execute(FileUtils.getFile(getContext(), msg.getImageUri()));
            // set up the background
            View background = new View(getContext());
            background.setLayoutParams(backgroundParams);
            background.setBackgroundColor(getActivity().getResources().getColor(R.color.colorPrimaryDark));
            // make it invisible in the beginning
            background.setVisibility(View.GONE);

            // create the relativeLayout containing them
            RelativeLayout relativeLayout = new RelativeLayout(getContext());
            relativeLayout.setLayoutParams(relativeLayoutParams);
            relativeLayout.addView(background);
            relativeLayout.addView(imageView);
            // combination of Message and overviewViews
            msg.setLayout(relativeLayout);
            msg.setBackground(background);
            linearLayout.addView(relativeLayout);
        }
    } else
        getActivity().findViewById(R.id.send_image_overview).setVisibility(View.GONE);
    changePage(current, true, true);
    showSystemUI();
}

From source file:com.mobileman.moments.android.frontend.fragments.StreamListFragment.java

private void doIt() {

    //        View v = ((LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.overlay_thumbnail, null, false);
    /*    Bitmap overlayBitmap = Bitmap.createBitmap(getResources().getDimensionPixelOffset(R.dimen.thumbnailWidth), getResources().getDimensionPixelOffset(R.dimen.thumbnailHeight),Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(overlayBitmap);
    Drawable bgDrawable = overlayView.getBackground();
    if (bgDrawable!=null)/* w  ww . j  a v  a2s  . c o m*/
    bgDrawable.draw(canvas);
    else
    canvas.drawColor(Color.WHITE);
    overlayView.draw(canvas);
            
    */
    LayoutInflater mInflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    //Inflate the layout into a view and configure it the way you like
    RelativeLayout view = new RelativeLayout(getActivity());
    mInflater.inflate(R.layout.overlay_thumbnail, view, true);
    //        TextView tv = (TextView) findViewById(R.id.my_text);
    //        tv.setText("Beat It!!");

    //Provide it with a layout params. It should necessarily be wrapping the
    //content as we not really going to have a parent for it.
    view.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
            RelativeLayout.LayoutParams.WRAP_CONTENT));

    //Pre-measure the view so that height and width don't remain null.
    view.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
            View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));

    //Assign a size and position to the view and all of its descendants
    view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());

    //Create the bitmap
    Bitmap bitmap = Bitmap.createBitmap(view.getMeasuredWidth(), view.getMeasuredHeight(),
            Bitmap.Config.ARGB_8888);
    //Create a canvas with the specified bitmap to draw into
    Canvas c = new Canvas(bitmap);

    //Render this view (and all of its children) to the given Canvas
    view.draw(c);

    String path = Environment.getExternalStorageDirectory().toString();
    OutputStream fOut = null;
    File file = new File(path, "testing.jpg"); // the File to save to
    try {
        fOut = new FileOutputStream(file);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }

    bitmap.compress(Bitmap.CompressFormat.JPEG, 85, fOut); // saving the Bitmap to a file compressed as a JPEG with 85% compression rate
    try {
        fOut.flush();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        try {
            fOut.close(); // do not forget to close the stream
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}