Android Open Source - android-cassowary-layout Layout Params Switcher Activity






From Project

Back to project page android-cassowary-layout.

License

The source code is released under:

Apache License

If you think the Android project android-cassowary-layout listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package no.agens.cassowarylayoutdemo;
// w  ww .  j  a va  2 s  .  c  o m
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RadioGroup;

/**
 * Created by alex on 19/11/2014.
 */
public abstract class LayoutParamsSwitcherActivity extends Activity {


    private View contentView;

    private RadioGroup.OnCheckedChangeListener buttonListener = new RadioGroup.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            switch (checkedId) {
                case R.id.width_wrap_content:
                    contentView.getLayoutParams().width = ViewGroup.LayoutParams.WRAP_CONTENT;
                    break;
                case R.id.width_match_parent:
                    contentView.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
                    break;
                case R.id.height_wrap_content:
                    contentView.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT;
                    break;
                case R.id.height_match_parent:
                    contentView.getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT;
                    break;
            }
            contentView.requestLayout();
        }
    };

    @Override
    public void setContentView(int layoutResID) {
        LayoutInflater li = LayoutInflater.from(this);
        setContentView(li.inflate(layoutResID, null));
    }

    @Override
    public void setContentView(View contentView) {
        this.contentView = contentView;
        LayoutInflater li = LayoutInflater.from(this);

        ViewGroup layoutParamsSwitcher = (ViewGroup)li.inflate(R.layout.activity_layout_params_switcher, null);
        layoutParamsSwitcher.addView(contentView);

        super.setContentView(layoutParamsSwitcher);
        addListeners();

        contentView.getLayoutParams().width = ViewGroup.LayoutParams.WRAP_CONTENT;
        contentView.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT;
    }

    private void addListeners() {
        ((RadioGroup) findViewById(R.id.layout_width_radio_group)).setOnCheckedChangeListener(buttonListener);
        ((RadioGroup) findViewById(R.id.layout_height_radio_group)).setOnCheckedChangeListener(buttonListener);
    }

}




Java Source Code List

no.agens.cassowarylayout.ApplicationTest.java
no.agens.cassowarylayout.CassowaryLayout.java
no.agens.cassowarylayout.CassowaryModel.java
no.agens.cassowarylayout.ChildNode.java
no.agens.cassowarylayout.ConstraintParser.java
no.agens.cassowarylayout.ContainerNode.java
no.agens.cassowarylayout.DefaultViewIdResolver.java
no.agens.cassowarylayout.Node.java
no.agens.cassowarylayout.ViewIdResolver.java
no.agens.cassowarylayout.util.CassowaryUtil.java
no.agens.cassowarylayout.util.DimensionParserTest.java
no.agens.cassowarylayout.util.DimensionParser.java
no.agens.cassowarylayout.util.ExpressionTokenizerTest.java
no.agens.cassowarylayout.util.InfixToPostFixTest.java
no.agens.cassowarylayout.util.MeasureSpecUtils.java
no.agens.cassowarylayout.util.TimerUtil.java
no.agens.cassowarylayoutdemo.ApplicationTest.java
no.agens.cassowarylayoutdemo.CassowaryLayoutInLinearLayoutActivity.java
no.agens.cassowarylayoutdemo.CassowaryLayoutMatchParentActivity.java
no.agens.cassowarylayoutdemo.CassowaryLayoutWrapContentActivity.java
no.agens.cassowarylayoutdemo.CassowaryLayoutsInCassowaryLayoutActivity.java
no.agens.cassowarylayoutdemo.CassowaryLayoutsInListViewActivity.java
no.agens.cassowarylayoutdemo.CenterInParentActivity.java
no.agens.cassowarylayoutdemo.CenterViewRelativeToSiblingActivity.java
no.agens.cassowarylayoutdemo.ChessBoardActivity.java
no.agens.cassowarylayoutdemo.DynamicWidthActivity.java
no.agens.cassowarylayoutdemo.ExampleMenuActivity.java
no.agens.cassowarylayoutdemo.FixedAspectRatioDemoActivity.java
no.agens.cassowarylayoutdemo.IntrinsicHeightTextInWrapContentContainerActivity.java
no.agens.cassowarylayoutdemo.LayoutParamsSwitcherActivity.java
no.agens.cassowarylayoutdemo.LinearLayoutInCassowaryLayoutActivity.java
no.agens.cassowarylayoutdemo.ParallaxScrollingActivity.java
no.agens.cassowarylayoutdemo.PreSetupTestActivity.java
no.agens.cassowarylayoutdemo.ProgrammaticDemoActivity.java
no.agens.cassowarylayoutdemo.XmlLayoutDemoActivity.java
no.agens.cassowarylayoutdemo.util.EditRatioDialog.java