Android FrameLayout - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android FrameLayout class.

This code example shows how to use the following methods:setBackgroundColor, setLayoutParams, setVisibility, addView, addContentView
This code example shows how to use the following methods:measure, setBackground, layout, draw, dispatchOnPreDraw
                    drawableResource.getResourceType() != ResourceType.DRAWABLE) {
                return Status.ERROR_NOT_A_DRAWABLE.createResult(); 
            } 
 
            // create a simple FrameLayout 
            FrameLayout content = new FrameLayout(context);
 
            // get the actual Drawable object to draw 
            Drawable d = ResourceHelper.getDrawable(drawableResource, context);
            content.setBackground(d);
 
            // set the AttachInfo on the root view. 
            AttachInfo_Accessor.setAttachInfo(content);
 
 
            // measure 
            int w = hardwareConfig.getScreenWidth();
            int h = hardwareConfig.getScreenHeight();
            int w_spec = MeasureSpec.makeMeasureSpec(w, MeasureSpec.EXACTLY);
            int h_spec = MeasureSpec.makeMeasureSpec(h, MeasureSpec.EXACTLY);

9
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setLayoutParams, setOnTouchListener, addView
This code example shows how to use the following methods:setBackgroundColor, addView
public class MoreNinePatchesActivity extends Activity {
    @Override 
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         
        FrameLayout layout = new FrameLayout(this);
        PatchView b = new PatchView (this);
        b.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
                FrameLayout.LayoutParams.MATCH_PARENT, Gravity.CENTER));
        layout.addView(b);
        layout.setBackgroundColor(0xffffffff);
         
        setContentView(layout);
    } 
 
    private class PatchView extends View {
        private final Drawable mDrawable1;
        private final Drawable mDrawable2;
        private final Drawable mDrawable3;
 
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:measure, setBackgroundDrawable, layout, draw, dispatchOnPreDraw
                    drawableResource.getResourceType() != ResourceType.DRAWABLE) {
                return Status.ERROR_NOT_A_DRAWABLE.createResult(); 
            } 
 
            // create a simple FrameLayout 
            FrameLayout content = new FrameLayout(context);
 
            // get the actual Drawable object to draw 
            Drawable d = ResourceHelper.getDrawable(drawableResource, context);
            content.setBackgroundDrawable(d);
 
            // set the AttachInfo on the root view. 
            AttachInfo_Accessor.setAttachInfo(content);
 
 
            // measure 
            int w = params.getScreenWidth();
            int h = params.getScreenHeight();
            int w_spec = MeasureSpec.makeMeasureSpec(w, MeasureSpec.EXACTLY);
            int h_spec = MeasureSpec.makeMeasureSpec(h, MeasureSpec.EXACTLY);

8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setLayoutParams, addView
     * way to have the built-in indeterminant progress state be shown. 
     */ 
    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        FrameLayout root = new FrameLayout(getActivity());
 
        TextView tv = new TextView(getActivity());
        tv.setId(INTERNAL_EMPTY_ID);
        tv.setGravity(Gravity.CENTER);
        root.addView(tv, new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
 
        ExpandableListView lv = new ExpandableListView(getActivity());
        lv.setId(android.R.id.list);
        lv.setDrawSelectorOnTop(false);
        root.addView(lv, new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
 
        ListView.LayoutParams lp = new ListView.LayoutParams(

8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addView
public class Bitmaps3dActivity extends Activity {
    @Override 
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        final BitmapsView view = new BitmapsView(this);
        final FrameLayout layout = new FrameLayout(this);
        layout.addView(view, new FrameLayout.LayoutParams(800, 400, Gravity.CENTER));
        view.setRotationX(-35.0f);
        setContentView(layout);
    } 
 
    static class BitmapsView extends View {
        private final Paint mBitmapPaint;
        private final Bitmap mBitmap1;
        private Matrix mMatrix;
 
        BitmapsView(Context c) {
            super(c);
 
            mBitmap1 = BitmapFactory.decodeResource(c.getResources(), R.drawable.sunset1);
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addView
public class TimeDialogActivity extends Activity {
    @Override 
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         
        FrameLayout layout = new FrameLayout(this);
        Button b = new Button(this);
        b.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT,
                FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER));
        b.setText("Show dialog");
        b.setOnClickListener(new View.OnClickListener() {
            @Override 
            public void onClick(View v) {
                new TimePickerDialog(TimeDialogActivity.this, null, 12, 12, true).show();
            } 
        }); 
        layout.addView(b);
         
        setContentView(layout);
    } 

8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addView
 
    @Override 
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 
        FrameLayout content = new FrameLayout(this);
 
        mTextureView = new TextureView(this);
        mTextureView.setSurfaceTextureListener(this);
 
        Button button = new Button(this);
        button.setText("Copy bitmap to /sdcard/textureview.png");
        button.setOnClickListener(new View.OnClickListener() {
            @Override 
            public void onClick(View v) {
                Bitmap b = mTextureView.getBitmap();
                try { 
                    FileOutputStream out = new FileOutputStream(
                            Environment.getExternalStorageDirectory() + "/textureview.png");
                    try { 

7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addView
        setContentView(container);
 
        container.addView(slider);
        slider.setMax(100);
        slider.setProgress(50);
        FrameLayout frame = new FrameLayout(this);
        final RenderingView gpuView = new RenderingView(this, Color.GREEN);
        frame.addView(gpuView);
        final RenderingView swView = new RenderingView(this, Color.RED);
        swView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        frame.addView(swView);
        container.addView(frame);
 
        slider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override 
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                mSeekValue = (float)progress / 100.0f;
                float gpuAlpha = Math.min(2.0f * mSeekValue, 1f);
                gpuView.setAlpha(gpuAlpha);
                float swAlpha = Math.min((1 - mSeekValue) * 2.0f, 1f);
7
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Android FrameLayout Questions & Answers:

See Code Examples for Android FrameLayout Methods: