Example usage for android.widget FrameLayout.LayoutParams FrameLayout.LayoutParams

List of usage examples for android.widget FrameLayout.LayoutParams FrameLayout.LayoutParams

Introduction

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

Prototype

public LayoutParams(int width, int height) 

Source Link

Usage

From source file:com.baidu.android.voicedemo.ActivityTouch.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.sdk2_api);//from   ww w  .j  ava  2 s.co  m
    txtResult = (TextView) findViewById(R.id.txtResult);
    txtLog = (TextView) findViewById(R.id.txtLog);
    btn = (Button) findViewById(R.id.btn);
    setting = (Button) findViewById(R.id.setting);
    setting.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent("com.baidu.speech.asr.demo.setting");
            startActivity(intent);
        }
    });
    speechRecognizer = SpeechRecognizer.createSpeechRecognizer(this,
            new ComponentName(this, VoiceRecognitionService.class));
    speechRecognizer.setRecognitionListener(this);

    speechTips = View.inflate(this, R.layout.bd_asr_popup_speech, null);
    speechWave = speechTips.findViewById(R.id.wave);
    speechTips.setVisibility(View.GONE);
    addContentView(speechTips, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    btn.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                speechTips.setVisibility(View.VISIBLE);
                speechRecognizer.cancel();
                Intent intent = new Intent();
                bindParams(intent);
                intent.putExtra("vad", "touch");
                txtResult.setText("");
                txtLog.setText("");
                speechRecognizer.startListening(intent);
                return true;
            case MotionEvent.ACTION_UP:
                speechRecognizer.stopListening();
                speechTips.setVisibility(View.GONE);
                break;
            }
            return false;
        }
    });
}

From source file:org.xbmc.android.app.ui.fragment.GridFragment.java

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

    FrameLayout root = new FrameLayout(context);

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

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

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

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

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

    FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);

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

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

    root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

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

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

    return root;
}

From source file:com.l4digital.fastscroll.FastScrollRecyclerView.java

@Override
protected void onAttachedToWindow() {
    super.onAttachedToWindow();
    mFastScroller.attachRecyclerView(this);

    final ViewParent parent = getParent();

    if (parent instanceof ViewGroup) {
        final ViewGroup viewGroup = (ViewGroup) parent;
        if ((viewGroup instanceof CoordinatorLayout) || (viewGroup instanceof FrameLayout)
                || (viewGroup instanceof RelativeLayout)) {
            if (mFastScroller.getParent() == null) {
                viewGroup.addView(mFastScroller);
                mFastScroller.setLayoutParams(viewGroup);
            }//w  w  w . jav  a2 s.c  om
        } else {
            if (viewGroup instanceof SwipeRefreshLayout) {
                mFastScroller.swipeRefreshLayout = (SwipeRefreshLayout) viewGroup;
            }
            final int index = viewGroup.indexOfChild(this);
            viewGroup.removeView(this);
            final FrameLayout fr = new FrameLayout(getContext());
            fr.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
                    FrameLayout.LayoutParams.MATCH_PARENT));
            fr.addView(this);
            fr.addView(mFastScroller);
            mFastScroller.setLayoutParams(fr);
            viewGroup.addView(fr, index);
        }
    }
}

From source file:gov.sfmta.sfpark.MainScreenActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    MYLOG("onCreate");

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);//from  w  w  w  . j a  va  2s.  co m

    // Set up ActionBar
    ActionBar ab = getSupportActionBar();
    ab.setDisplayShowTitleEnabled(false);
    ab.setIcon(R.drawable.logo_header);
    ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    ab.addTab(ab.newTab().setText("Price").setTabListener(new TabListener()));
    ab.addTab(ab.newTab().setText("Availability").setTabListener(new TabListener()));

    // Dropdown navigation
    final String[] dropdownValues = getResources().getStringArray(R.array.dropdown);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(ab.getThemedContext(),
            R.layout.sherlock_spinner_item, android.R.id.text1, dropdownValues);
    adapter.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item);
    ab.setListNavigationCallbacks(adapter, this);

    if (SFparkActivity.DEBUG) {
        debugText = (TextView) findViewById(R.id.debugText);
        debugText.setText("Debug String");
        debugText.setVisibility(View.VISIBLE);
    }

    legendlabel = (TextView) findViewById(R.id.legendText);
    legendImage = (ImageView) findViewById(R.id.keyImage);

    // DoubleTapMapView... is a mapview that you can double-tap. :-/
    mapView = new DoubleTapMapView(this);
    FrameLayout fl = (FrameLayout) findViewById(R.id.mapframe);
    fl.addView(mapView, 0, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    mapView.setBuiltInZoomControls(true);
    mc = mapView.getController();

    // Creating and initializing Map
    GeoPoint p = getPoint(INITIAL_LATITUDE, INITIAL_LONGITUDE);

    mc.setCenter(p);
    mc.setZoom(14);

    startLocation();

    showPrice = true;

    enablePanToMe();
    reset();
}

From source file:com.vuze.android.remote.AndroidUtilsUI.java

public static AlertDialog.Builder createTextBoxDialog(Context context, int newtag_title, int newtag_hint,
        final OnTextBoxDialogClick onClickListener) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);

    FrameLayout container = new FrameLayout(context);
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.CENTER_VERTICAL;
    container.setMinimumHeight(AndroidUtilsUI.dpToPx(100));
    int padding = AndroidUtilsUI.dpToPx(20);
    params.leftMargin = padding;/* www  .  ja v a  2s . com*/
    params.rightMargin = padding;

    final MaterialEditText textView = AndroidUtilsUI.createFancyTextView(context);
    textView.setHint(newtag_hint);
    textView.setFloatingLabelText(context.getResources().getString(newtag_hint));
    textView.setSingleLine();
    textView.setLayoutParams(params);

    container.addView(textView);

    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
        builder.setInverseBackgroundForced(true);
    }

    builder.setView(container);
    builder.setTitle(newtag_title);
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            onClickListener.onClick(dialog, which, textView);
        }
    });
    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
        }
    });
    return builder;
}