Example usage for android.widget FrameLayout setLayoutParams

List of usage examples for android.widget FrameLayout setLayoutParams

Introduction

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

Prototype

public void setLayoutParams(ViewGroup.LayoutParams params) 

Source Link

Document

Set the layout parameters associated with this view.

Usage

From source file:com.example.diplimadoapp.SuperAwesomeCardFragment.java

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

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

    FrameLayout fl = new FrameLayout(getActivity());
    fl.setLayoutParams(params);

    final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
            getResources().getDisplayMetrics());

    switch (position) {
    case 0:/*from w  w  w  .  ja va 2 s.c o  m*/

        LinearLayout ll = new LinearLayout(getActivity());
        ll.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        ll.setOrientation(LinearLayout.VERTICAL);

        ImageView iv = new ImageView(getActivity());
        iv.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 1020));
        //iv.setLayoutParams(new  LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT));
        iv.setMaxHeight(520);
        iv.setImageResource(R.drawable.contact);
        ll.addView(iv);

        TableLayout tl = new TableLayout(getActivity());
        tl.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

        TableRow tr = new TableRow(getActivity());
        tr.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        tr.setGravity(Gravity.FILL_HORIZONTAL);
        tr.setPadding(5, 5, 5, 5);

        List<RssItem> lecturaitems = null;
        try {
            // Create RSS reader
            RssReader rssReader = new RssReader(
                    "http://www.senalradionica.gov.co/index.php/home/articulos/itemlist?format=feed");
            // Get a ListView from main view
            //ListView itcItems = (ListView) findViewById(R.id.listMainView);

            lecturaitems = rssReader.getItems();

        } catch (Exception e) {
            Log.e("Diplomado App Reader", e.getMessage());
        }

        TextView v1 = new TextView(getActivity());
        params.setMargins(margin, margin, margin, margin);
        v1.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2));
        v1.setGravity(Gravity.CENTER);
        v1.setBackgroundResource(R.drawable.background_card);
        if (lecturaitems != null) {
            v1.setText(lecturaitems.get(0).getTitle());
            String urlnoticia = lecturaitems.get(0).getLink();
            v1.setOnClickListener(new NoticiaDestacadaOnClickListener(urlnoticia));
        } else {
            v1.setText("No Registra nuevas noticias");
        }

        tr.addView(v1);

        ImageButton ib = new ImageButton(getActivity());
        ib.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1));
        ib.setImageResource(R.drawable.facebook);

        ib.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW);
                myWebLink.setData(Uri.parse("http://www.facebook.com"));
                startActivity(myWebLink);
            }
        });

        tr.addView(ib);

        ImageButton ib2 = new ImageButton(getActivity());
        ib2.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1));
        ib2.setImageResource(R.drawable.twitter);

        ib2.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW);
                myWebLink.setData(Uri.parse("http://www.twitter.com"));
                startActivity(myWebLink);
            }
        });

        tr.addView(ib2);

        ImageButton ib3 = new ImageButton(getActivity());
        ib3.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1));
        ib3.setImageResource(R.drawable.youtube);

        ib3.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW);
                myWebLink.setData(Uri.parse("http://www.youtube.com"));
                startActivity(myWebLink);
            }
        });

        tr.addView(ib3);

        tl.addView(tr);

        ll.addView(tl);

        fl.addView(ll);

        break;

    case 1:

        LinearLayout ll2 = new LinearLayout(getActivity());
        ll2.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        ll2.setOrientation(LinearLayout.VERTICAL);

        TableLayout tl2 = new TableLayout(getActivity());
        tl2.setLayoutParams(
                new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

        TableRow tr2 = new TableRow(getActivity());
        tr2.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        tr2.setGravity(Gravity.FILL_HORIZONTAL);
        tr2.setPadding(5, 5, 5, 5);

        TextView v0 = new TextView(getActivity());
        params.setMargins(margin, margin, margin, margin);
        v0.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2));
        v0.setGravity(Gravity.CENTER);
        v0.setText("Acusticos Radionoca. Lunes a Viernes 8:00 a.m. - 9:00 a.m.");
        tr2.addView(v0);

        ImageButton ib20 = new ImageButton(getActivity());
        ib20.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1));
        ib20.setImageResource(R.drawable.pacusticos);
        ib20.setBackgroundDrawable(null);

        tr2.addView(ib20);

        tl2.addView(tr2);

        TableRow tr3 = new TableRow(getActivity());
        tr3.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        tr3.setGravity(Gravity.FILL_HORIZONTAL);
        tr3.setPadding(5, 5, 5, 5);

        TextView v03 = new TextView(getActivity());
        params.setMargins(margin, margin, margin, margin);
        v03.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2));
        v03.setGravity(Gravity.CENTER);
        v03.setText("Acusticos Radionoca. Lunes a Viernes 8:00 a.m. - 9:00 a.m.");
        tr3.addView(v03);

        ImageButton ib30 = new ImageButton(getActivity());
        ib30.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1));
        ib30.setImageResource(R.drawable.pradionica_lacarta);
        ib30.setBackgroundDrawable(null);

        tr3.addView(ib30);

        tl2.addView(tr3);

        TableRow tr4 = new TableRow(getActivity());
        tr4.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        tr4.setGravity(Gravity.FILL_HORIZONTAL);
        tr4.setPadding(5, 5, 5, 5);

        TextView v04 = new TextView(getActivity());
        params.setMargins(margin, margin, margin, margin);
        v04.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2));
        v04.setGravity(Gravity.CENTER);
        v04.setText("Acusticos Radionoca. Lunes a Viernes 8:00 a.m. - 9:00 a.m.");
        tr4.addView(v04);

        tl2.addView(tr4);

        ImageButton ib40 = new ImageButton(getActivity());
        ib40.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1));
        ib40.setImageResource(R.drawable.prockeros);
        ib40.setBackgroundDrawable(null);

        tr4.addView(ib40);

        ll2.addView(tl2);

        /*
        VideoView videoView = new VideoView(getActivity());
                
        Uri path = Uri.parse("rtmp://cdns840stu0010.multistream.net:80/rtvcRadionicalive/?pass=|radionica|");
                
        videoView.setVideoURI(path);
        videoView.start(); 
                
        TableRow tr5 =new TableRow(getActivity());
        tr5.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
        tr5.setGravity(Gravity.FILL_HORIZONTAL);
        tr5.setPadding(5,5,5,5);
        tr5.addView(videoView);
                
        ll2.addView(tr5);*/

        fl.addView(ll2);
        break;
    case 2:
        ListView lv = new ListView(getActivity());
        params.setMargins(margin, margin, margin, margin);
        lv.setLayoutParams(params);
        lv.setLayoutParams(params);
        lv.setBackgroundResource(R.drawable.background_card);
        try {
            // Create RSS reader
            RssReader rssReader = new RssReader(
                    "http://www.senalradionica.gov.co/index.php/home/articulos/itemlist?format=feed");
            // Get a ListView from main view
            //ListView itcItems = (ListView) findViewById(R.id.listMainView);

            List<RssItem> lecturaitems2 = rssReader.getItems();
            // Create a list adapter
            ArrayAdapter<RssItem> adapter = new ArrayAdapter<RssItem>(getActivity(),
                    android.R.layout.simple_list_item_1, lecturaitems2);
            // Set list adapter for the ListView
            lv.setAdapter(adapter);

            // Set list view item click listener
            lv.setOnItemClickListener(new ListListener(lecturaitems2, getActivity()));

        } catch (Exception e) {
            Log.e("Diplomado App Reader", e.getMessage());
        }
        fl.addView(lv);
        break;
    }

    return fl;
}

From source file:io.flutter.embedding.android.FlutterActivity.java

/**
 * Creates a {@link FrameLayout} with an ID of {@code #FRAGMENT_CONTAINER_ID} that will contain
 * the {@link FlutterFragment} displayed by this {@code FlutterActivity}.
 * <p>//from w ww . ja  va2 s .co  m
 * @return the FrameLayout container
 */
@NonNull
private View createFragmentContainer() {
    FrameLayout container = new FrameLayout(this);
    container.setId(FRAGMENT_CONTAINER_ID);
    container.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    return container;
}

From source file:com.nttec.everychan.http.recaptcha.Recaptcha2fallback.java

@Override
public void handle(final Activity activity, final CancellableTask task, final Callback callback) {
    try {// ww w  .ja v  a2s.  c  o m
        final HttpClient httpClient = ((HttpChanModule) MainApplication.getInstance().getChanModule(chanName))
                .getHttpClient();
        final String usingURL = scheme + RECAPTCHA_FALLBACK_URL + publicKey
                + (sToken != null && sToken.length() > 0 ? ("&stoken=" + sToken) : "");
        String refererURL = baseUrl != null && baseUrl.length() > 0 ? baseUrl : usingURL;
        Header[] customHeaders = new Header[] { new BasicHeader(HttpHeaders.REFERER, refererURL) };
        String htmlChallenge;
        if (lastChallenge != null && lastChallenge.getLeft().equals(usingURL)) {
            htmlChallenge = lastChallenge.getRight();
        } else {
            htmlChallenge = HttpStreamer.getInstance().getStringFromUrl(usingURL,
                    HttpRequestModel.builder().setGET().setCustomHeaders(customHeaders).build(), httpClient,
                    null, task, false);
        }
        lastChallenge = null;

        Matcher challengeMatcher = Pattern.compile("name=\"c\" value=\"([\\w-]+)").matcher(htmlChallenge);
        if (challengeMatcher.find()) {
            final String challenge = challengeMatcher.group(1);
            HttpResponseModel responseModel = HttpStreamer.getInstance().getFromUrl(
                    scheme + RECAPTCHA_IMAGE_URL + challenge + "&k=" + publicKey,
                    HttpRequestModel.builder().setGET().setCustomHeaders(customHeaders).build(), httpClient,
                    null, task);
            try {
                InputStream imageStream = responseModel.stream;
                final Bitmap challengeBitmap = BitmapFactory.decodeStream(imageStream);

                final String message;
                Matcher messageMatcher = Pattern.compile("imageselect-message(?:.*?)>(.*?)</div>")
                        .matcher(htmlChallenge);
                if (messageMatcher.find())
                    message = RegexUtils.removeHtmlTags(messageMatcher.group(1));
                else
                    message = null;

                final Bitmap candidateBitmap;
                Matcher candidateMatcher = Pattern
                        .compile("fbc-imageselect-candidates(?:.*?)src=\"data:image/(?:.*?);base64,([^\"]*)\"")
                        .matcher(htmlChallenge);
                if (candidateMatcher.find()) {
                    Bitmap bmp = null;
                    try {
                        byte[] imgData = Base64.decode(candidateMatcher.group(1), Base64.DEFAULT);
                        bmp = BitmapFactory.decodeByteArray(imgData, 0, imgData.length);
                    } catch (Exception e) {
                    }
                    candidateBitmap = bmp;
                } else
                    candidateBitmap = null;

                activity.runOnUiThread(new Runnable() {
                    final int maxX = 3;
                    final int maxY = 3;
                    final boolean[] isSelected = new boolean[maxX * maxY];

                    @SuppressLint("InlinedApi")
                    @Override
                    public void run() {
                        LinearLayout rootLayout = new LinearLayout(activity);
                        rootLayout.setOrientation(LinearLayout.VERTICAL);

                        if (candidateBitmap != null) {
                            ImageView candidateView = new ImageView(activity);
                            candidateView.setImageBitmap(candidateBitmap);
                            int picSize = (int) (activity.getResources().getDisplayMetrics().density * 50
                                    + 0.5f);
                            candidateView.setLayoutParams(new LinearLayout.LayoutParams(picSize, picSize));
                            candidateView.setScaleType(ImageView.ScaleType.FIT_XY);
                            rootLayout.addView(candidateView);
                        }

                        if (message != null) {
                            TextView textView = new TextView(activity);
                            textView.setText(message);
                            CompatibilityUtils.setTextAppearance(textView, android.R.style.TextAppearance);
                            textView.setLayoutParams(
                                    new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                                            LinearLayout.LayoutParams.WRAP_CONTENT));
                            rootLayout.addView(textView);
                        }

                        FrameLayout frame = new FrameLayout(activity);
                        frame.setLayoutParams(
                                new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                                        LinearLayout.LayoutParams.WRAP_CONTENT));

                        final ImageView imageView = new ImageView(activity);
                        imageView.setLayoutParams(new FrameLayout.LayoutParams(
                                FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
                        imageView.setScaleType(ImageView.ScaleType.FIT_XY);
                        imageView.setImageBitmap(challengeBitmap);
                        frame.addView(imageView);

                        final LinearLayout selector = new LinearLayout(activity);
                        selector.setLayoutParams(new FrameLayout.LayoutParams(
                                FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
                        AppearanceUtils.callWhenLoaded(imageView, new Runnable() {
                            @Override
                            public void run() {
                                selector.setLayoutParams(new FrameLayout.LayoutParams(imageView.getWidth(),
                                        imageView.getHeight()));
                            }
                        });
                        selector.setOrientation(LinearLayout.VERTICAL);
                        selector.setWeightSum(maxY);
                        for (int y = 0; y < maxY; ++y) {
                            LinearLayout subSelector = new LinearLayout(activity);
                            subSelector.setLayoutParams(new LinearLayout.LayoutParams(
                                    LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f));
                            subSelector.setOrientation(LinearLayout.HORIZONTAL);
                            subSelector.setWeightSum(maxX);
                            for (int x = 0; x < maxX; ++x) {
                                FrameLayout switcher = new FrameLayout(activity);
                                switcher.setLayoutParams(new LinearLayout.LayoutParams(0,
                                        LinearLayout.LayoutParams.MATCH_PARENT, 1f));
                                switcher.setTag(new int[] { x, y });
                                switcher.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View v) {
                                        int[] coord = (int[]) v.getTag();
                                        int index = coord[1] * maxX + coord[0];
                                        isSelected[index] = !isSelected[index];
                                        v.setBackgroundColor(isSelected[index] ? Color.argb(128, 0, 255, 0)
                                                : Color.TRANSPARENT);
                                    }
                                });
                                subSelector.addView(switcher);
                            }
                            selector.addView(subSelector);
                        }

                        frame.addView(selector);
                        rootLayout.addView(frame);

                        Button checkButton = new Button(activity);
                        checkButton.setLayoutParams(
                                new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                                        LinearLayout.LayoutParams.WRAP_CONTENT));
                        checkButton.setText(android.R.string.ok);
                        rootLayout.addView(checkButton);

                        ScrollView dlgView = new ScrollView(activity);
                        dlgView.addView(rootLayout);

                        final Dialog dialog = new Dialog(activity);
                        dialog.setTitle("Recaptcha");
                        dialog.setContentView(dlgView);
                        dialog.setCanceledOnTouchOutside(false);
                        dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
                            @Override
                            public void onCancel(DialogInterface dialog) {
                                if (!task.isCancelled()) {
                                    callback.onError("Cancelled");
                                }
                            }
                        });
                        dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT,
                                ViewGroup.LayoutParams.WRAP_CONTENT);
                        dialog.show();

                        checkButton.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                dialog.dismiss();
                                if (task.isCancelled())
                                    return;
                                Async.runAsync(new Runnable() {
                                    @Override
                                    public void run() {
                                        try {
                                            List<NameValuePair> pairs = new ArrayList<NameValuePair>();
                                            pairs.add(new BasicNameValuePair("c", challenge));
                                            for (int i = 0; i < isSelected.length; ++i)
                                                if (isSelected[i])
                                                    pairs.add(new BasicNameValuePair("response",
                                                            Integer.toString(i)));

                                            HttpRequestModel request = HttpRequestModel.builder()
                                                    .setPOST(new UrlEncodedFormEntity(pairs, "UTF-8"))
                                                    .setCustomHeaders(new Header[] {
                                                            new BasicHeader(HttpHeaders.REFERER, usingURL) })
                                                    .build();
                                            String response = HttpStreamer.getInstance().getStringFromUrl(
                                                    usingURL, request, httpClient, null, task, false);
                                            String hash = "";
                                            Matcher matcher = Pattern.compile(
                                                    "fbc-verification-token(?:.*?)<textarea[^>]*>([^<]*)<",
                                                    Pattern.DOTALL).matcher(response);
                                            if (matcher.find())
                                                hash = matcher.group(1);

                                            if (hash.length() > 0) {
                                                Recaptcha2solved.push(publicKey, hash);
                                                activity.runOnUiThread(new Runnable() {
                                                    @Override
                                                    public void run() {
                                                        callback.onSuccess();
                                                    }
                                                });
                                            } else {
                                                lastChallenge = Pair.of(usingURL, response);
                                                throw new RecaptchaException(
                                                        "incorrect answer (hash is empty)");
                                            }
                                        } catch (final Exception e) {
                                            Logger.e(TAG, e);
                                            if (task.isCancelled())
                                                return;
                                            handle(activity, task, callback);
                                        }
                                    }
                                });
                            }
                        });
                    }
                });
            } finally {
                responseModel.release();
            }
        } else
            throw new Exception("can't parse recaptcha challenge answer");
    } catch (final Exception e) {
        Logger.e(TAG, e);
        if (!task.isCancelled()) {
            activity.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    callback.onError(e.getMessage() != null ? e.getMessage() : e.toString());
                }
            });
        }
    }
}

From source file:foam.starwisp.DrawableMap.java

public void init(int id, ViewGroup parent, StarwispActivity c, StarwispBuilder b, String mode) {
    m_parent = parent;/*from   ww w  .j  a v  a 2  s . c om*/
    map_ready = false;
    draw_mode = false;
    button_mode = false;
    m_Context = c;
    m_Builder = b;
    map_mode = mode;
    ID = id;
    current_polygon = new Vector<LatLng>();
    polygons = new Vector<Polygon>();
    centre_lat = 49.198935;
    centre_lon = 2.988281;
    centre_zoom = 4;
    draw_indicator = false;
    indicator_lat = 0;
    indicator_lon = 0;

    FrameLayout outer_map = new FrameLayout(c);
    outer_map.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT,
            FrameLayout.LayoutParams.FILL_PARENT));

    FrameLayout map_container = new FrameLayout(c);
    map_container.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT,
            FrameLayout.LayoutParams.FILL_PARENT));

    map_container.setId(ID);
    SupportMapFragment mapfrag = SupportMapFragment.newInstance();
    FragmentTransaction fragmentTransaction = c.getSupportFragmentManager().beginTransaction();
    fragmentTransaction.add(ID, mapfrag);
    fragmentTransaction.commit();
    outer_map.addView(map_container);

    fram_map = new FrameLayout(c);
    fram_map.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT,
            FrameLayout.LayoutParams.FILL_PARENT));
    outer_map.addView(fram_map);

    if (map_mode.equals("edit")) {
        map_cont = new LinearLayout(c);
        map_cont.setOrientation(LinearLayout.VERTICAL);
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
                LinearLayout.LayoutParams.FILL_PARENT);
        lp.gravity = Gravity.CENTER;
        map_cont.setLayoutParams(lp);

        scribble_button = new Button(c);
        lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        lp.gravity = Gravity.CENTER;
        scribble_button.setLayoutParams(lp);

        scribble_button.setTextSize(20);
        scribble_button.setTypeface(((StarwispActivity) c).m_Typeface);
        scribble_button.setText("Draw field");
        map_cont.addView(scribble_button);

        m_instructions = new TextView(c);
        m_instructions.setLayoutParams(lp);
        m_instructions.setTextSize(20);
        m_instructions.setTypeface(m_Context.m_Typeface);
        m_instructions.setTextColor(Color.WHITE);
        // arg i18n
        map_cont.addView(m_instructions);

        fram_map.addView(map_cont);

    } else {
        //button_mode=true;
    }

    parent.addView(outer_map);

    mapfrag.getMapAsync(new OnMapReadyCallback() {
        @Override
        public void onMapReady(GoogleMap googleMap) {
            map = googleMap;
            map.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
            map.setMyLocationEnabled(true);
            map.getUiSettings().setZoomControlsEnabled(true);
            SetupStuff();
            DrawMap();
            Log.i("starwisp", "map made");
            Log.i("starwisp", "updating map centre to " + centre_lat + " " + centre_lon);
            //CameraUpdate center_map=CameraUpdateFactory.newLatLng(new LatLng(centre_lat,centre_lon));
            //CameraUpdate zoom_map=CameraUpdateFactory.zoomTo(centre_zoom);
            //map.moveCamera(center_map);
            //map.animateCamera(zoom_map);

            CameraPosition cameraPosition = new CameraPosition.Builder()
                    .target(new LatLng(centre_lat, centre_lon)).zoom(centre_zoom).build();
            map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));

            map_ready = true;
        }
    });

}

From source file:io.nuclei.cyto.ui.view.BottomSheetView.java

private void init(Context context) {
    ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
    mMinFlingVelocity = viewConfiguration.getScaledMinimumFlingVelocity();
    mTouchSlop = viewConfiguration.getScaledTouchSlop();

    setClickable(true);//from www .  j  a  v a 2  s.  c om

    mBackground = new View(context);
    mBackground.setBackgroundColor(mBackgroundColor = DEFAULT_BACKGROUND_COLOR);
    mBackground.setLayoutParams(
            new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    mBackground.setVisibility(GONE);
    mBackground.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if ((mState & STATE_MOVING) != STATE_MOVING) {
                if ((mState & STATE_LOCKED) == STATE_LOCKED)
                    removeState(STATE_LOCKED);
                setState(STATE_CLOSED);
            }
        }
    });
    addView(mBackground);

    FrameLayout content = new FrameLayout(context);
    content.setLayoutParams(
            new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    content.setMinimumHeight(1);
    content.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
    content.setClickable(true);
    addView(content);
    mContent = content;
    mOffsetHelper = new ViewOffsetHelper(mContent);

    onPrepare();
}

From source file:com.github.jvanhie.discogsscrobbler.SearchFragment.java

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

    mList = new ExpandableListView(getActivity());
    mList.setAdapter(mAdapter);// w  w  w. j a  va 2s. c o m

    mList.setOnGroupClickListener(new GroupClickHandler());

    mList.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
        @Override
        public boolean onChildClick(ExpandableListView expandableListView, View view, final int i, int i2,
                long l) {
            if (l == 0) {
                //it's a loader (yes, hackish afterthought) get the necessary data from it
                DiscogsSearchLoader loader = (DiscogsSearchLoader) mAdapter.getChild(i, i2);
                mCallbacks.setRefreshVisible(true);
                if (loader.parenttype.equals("artist")) {
                    mDiscogs.getArtistReleases(loader.parentid, loader.page,
                            new Discogs.DiscogsDataWaiter<List<DiscogsSearchRelease>>() {
                                @Override
                                public void onResult(boolean success, List<DiscogsSearchRelease> data) {
                                    if (success) {
                                        mAdapter.addChildren(i, data);
                                    }
                                    mCallbacks.setRefreshVisible(false);
                                }
                            });
                } else if (loader.parenttype.equals("label")) {
                    mDiscogs.getLabelReleases(loader.parentid, loader.page,
                            new Discogs.DiscogsDataWaiter<List<DiscogsSearchRelease>>() {
                                @Override
                                public void onResult(boolean success, List<DiscogsSearchRelease> data) {
                                    if (success) {
                                        mAdapter.addChildren(i, data);
                                    }
                                    mCallbacks.setRefreshVisible(false);
                                }
                            });
                } else if (loader.parenttype.equals("master")) {
                    mDiscogs.getMasterReleases(loader.parentid, loader.page,
                            new Discogs.DiscogsDataWaiter<List<DiscogsSearchRelease>>() {
                                @Override
                                public void onResult(boolean success, List<DiscogsSearchRelease> data) {
                                    if (success) {
                                        mAdapter.addChildren(i, data);
                                    }
                                    mCallbacks.setRefreshVisible(false);
                                }
                            });
                }
            } else {
                //normal release selected
                onItemSelected(l);
            }

            return false;
        }
    });

    //create superframe for adding list and empty view
    FrameLayout superFrame = new FrameLayout(getActivity());
    FrameLayout.LayoutParams layoutparams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    superFrame.setLayoutParams(layoutparams);
    View emptyView = inflater.inflate(R.layout.fragment_empty, container, false);
    mEmptyHeading = ((TextView) emptyView.findViewById(R.id.empty_heading));
    mEmptyHeading.setText("Start searching Discogs");
    mEmptyText = ((TextView) emptyView.findViewById(R.id.empty_text));
    mEmptyText.setText("Enter a query or scan a barcode");

    if (mDiscogs == null)
        mDiscogs = Discogs.getInstance(getActivity());

    mList.setGroupIndicator(null);

    superFrame.addView(emptyView);
    mList.setEmptyView(emptyView);
    superFrame.addView(mList);

    return superFrame;
}

From source file:com.vaporwarecorp.mirror.component.dottedgrid.DottedGridView.java

private void initializeLayout(Context context) {
    mViews = new LinkedHashSet<>();

    FrameLayout gridLayout = new FrameLayout(context);
    gridLayout.setBackground(ContextCompat.getDrawable(context, R.drawable.bg_dotted_grid));
    gridLayout.setLayoutParams(new LayoutParams(MATCH_PARENT, MATCH_PARENT));

    mBackground = new FrameLayout(context);
    mBackground.addView(gridLayout);//from   w w w  . jav a2s. c o m
    mBackground.setLayoutParams(new LayoutParams(MATCH_PARENT, MATCH_PARENT));
    mBackground.setBackground(ContextCompat.getDrawable(context, R.drawable.bg_solid_border));
    mBackground.setVisibility(INVISIBLE);
    addView(mBackground);

    // now set the child clipping to false
    setClipChildren(false);
}

From source file:de.elanev.studip.android.app.frontend.courses.CourseDocumentsFragment.java

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

    final FrameLayout wrapperLayout = new FrameLayout(getActivity());
    wrapperLayout.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT));
    wrapperLayout.setId(R.id.document_list_wrapper);

    return wrapperLayout;
}

From source file:com.woodblockwithoutco.quickcontroldock.ui.factory.ServiceViewFactory.java

private void adjustPanelMargins(FrameLayout container) {
    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) container.getLayoutParams();
    params.topMargin = GeneralResolver.getPanelsMargin(mContext);
    params.bottomMargin = GeneralResolver.getPanelsMargin(mContext);
    container.setLayoutParams(params);
}

From source file:com.esri.android.ecologicalmarineunitexplorer.MainActivity.java

/**
 * Shrink layout for candlestick charts/*from  w ww  . j  av  a  2  s.c o  m*/
 */
private void shrinkChartContainer() {
    final FrameLayout layout = (FrameLayout) findViewById(R.id.chartContainer);
    if (layout != null) {
        layout.setLayoutParams(new LinearLayout.LayoutParams(0, 0));
        layout.requestLayout();
    }
}