Search in sources :

Example 56 with LayoutParams

use of android.widget.LinearLayout.LayoutParams in project Anki-Android by Ramblurr.

the class MultimediaCardEditorActivity method createNewViewer.

private void createNewViewer(LinearLayout linearLayout, final IField field, final int index) {
    final MultimediaCardEditorActivity context = this;
    switch(field.getType()) {
        case TEXT:
            // Create a text field and an edit button, opening editing for
            // the
            // text field
            TextView textView = new TextView(this);
            textView.setText(field.getText());
            linearLayout.addView(textView, LinearLayout.LayoutParams.MATCH_PARENT);
            break;
        case IMAGE:
            ImageView imgView = new ImageView(this);
            //
            // BitmapFactory.Options options = new BitmapFactory.Options();
            // options.inSampleSize = 2;
            // Bitmap bm = BitmapFactory.decodeFile(myJpgPath, options);
            // jpgView.setImageBitmap(bm);
            LinearLayout.LayoutParams p = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
            File f = new File(field.getImagePath());
            Bitmap b = BitmapUtil.decodeFile(f, getMaxImageSize());
            int currentapiVersion = android.os.Build.VERSION.SDK_INT;
            if (currentapiVersion >= android.os.Build.VERSION_CODES.ECLAIR) {
                b = ExifUtil.rotateFromCamera(f, b);
            }
            imgView.setImageBitmap(b);
            imgView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
            imgView.setAdjustViewBounds(true);
            DisplayMetrics metrics = new DisplayMetrics();
            getWindowManager().getDefaultDisplay().getMetrics(metrics);
            int height = metrics.heightPixels;
            int width = metrics.widthPixels;
            imgView.setMaxHeight((int) Math.round(height * 0.6));
            imgView.setMaxWidth((int) Math.round(width * 0.7));
            linearLayout.addView(imgView, p);
            break;
        case AUDIO:
            AudioView audioView = AudioView.createPlayerInstance(this, R.drawable.av_play, R.drawable.av_pause, R.drawable.av_stop, field.getAudioPath());
            linearLayout.addView(audioView);
            break;
        default:
            Log.e("multimedia editor", "Unsupported field type found");
            break;
    }
    Button editButtonText = new Button(this);
    editButtonText.setText(gtxt(R.string.multimedia_editor_activity_edit_button));
    linearLayout.addView(editButtonText, LinearLayout.LayoutParams.MATCH_PARENT);
    editButtonText.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent i = new Intent(context, EditFieldActivity.class);
            putExtrasAndStartEditActivity(field, index, i);
        }
    });
}
Also used : LayoutParams(android.widget.LinearLayout.LayoutParams) OnClickListener(android.view.View.OnClickListener) Intent(android.content.Intent) DisplayMetrics(android.util.DisplayMetrics) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) AudioView(com.ichi2.anki.multimediacard.AudioView) SuppressLint(android.annotation.SuppressLint) LayoutParams(android.widget.LinearLayout.LayoutParams) AudioView(com.ichi2.anki.multimediacard.AudioView) Bitmap(android.graphics.Bitmap) Button(android.widget.Button) TextView(android.widget.TextView) ImageView(android.widget.ImageView) File(java.io.File) LinearLayout(android.widget.LinearLayout)

Example 57 with LayoutParams

use of android.widget.LinearLayout.LayoutParams in project Anki-Android by Ramblurr.

the class MultimediaCardEditorActivity method initUI.

/**
     * Creates a TabBar in case action bar is not present as well as other UI Elements
     */
private void initUI() {
    int currentapiVersion = android.os.Build.VERSION.SDK_INT;
    if (currentapiVersion <= android.os.Build.VERSION_CODES.GINGERBREAD_MR1) {
        LinearLayout linearLayout = (LinearLayout) findViewById(R.id.LinearLayoutForSpareMenu);
        createSpareMenu(linearLayout);
    }
    mEditorLayout = (LinearLayout) findViewById(R.id.LinearLayoutInScrollView);
    LinearLayout mToolsLayout = (LinearLayout) findViewById(R.id.LinearLayoutForButtons);
    LayoutParams pars = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1);
    Button swapButton = new Button(this);
    swapButton.setText(gtxt(R.string.multimedia_editor_activity_swap_button));
    mToolsLayout.addView(swapButton, pars);
    swapButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            swap();
        }
    });
    LinearLayout mButtonsLayout = new LinearLayout(this);
    mButtonsLayout.setOrientation(LinearLayout.HORIZONTAL);
    mToolsLayout.addView(mButtonsLayout, pars);
    pars = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1);
    // DEPRECATED< BUT USED IN THE PROJECT.
    mModelButton = new Button(this);
    mModelButton.setOnClickListener(new OnClickListener() {

        @SuppressWarnings("deprecation")
        @Override
        public void onClick(View v) {
            showDialog(DIALOG_MODEL_SELECT);
        }
    });
    mButtonsLayout.addView(mModelButton, pars);
    mDeckButton = new Button(this);
    mDeckButton.setOnClickListener(new OnClickListener() {

        @SuppressWarnings("deprecation")
        @Override
        public void onClick(View v) {
            showDialog(DIALOG_DECK_SELECT);
        }
    });
    mButtonsLayout.addView(mDeckButton, pars);
}
Also used : LayoutParams(android.widget.LinearLayout.LayoutParams) LayoutParams(android.widget.LinearLayout.LayoutParams) Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) AudioView(com.ichi2.anki.multimediacard.AudioView) SuppressLint(android.annotation.SuppressLint) LinearLayout(android.widget.LinearLayout)

Example 58 with LayoutParams

use of android.widget.LinearLayout.LayoutParams in project Anki-Android by Ramblurr.

the class MultimediaCardEditorActivity method createSpareMenu.

private void createSpareMenu(LinearLayout linearLayout) {
    LayoutParams pars = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1);
    Button saveButton = new Button(this);
    saveButton.setText(getString(R.string.CardEditorSaveButton));
    saveButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            save();
        }
    });
    linearLayout.addView(saveButton, pars);
    Button deleteButton = new Button(this);
    deleteButton.setText(getString(R.string.menu_delete_note));
    deleteButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            delete();
        }
    });
    linearLayout.addView(deleteButton, pars);
}
Also used : LayoutParams(android.widget.LinearLayout.LayoutParams) Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) AudioView(com.ichi2.anki.multimediacard.AudioView)

Example 59 with LayoutParams

use of android.widget.LinearLayout.LayoutParams in project mobile-android by photo.

the class ImageFragment method onCreateView.

@Override
public View onCreateView(org.holoeverywhere.LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    TextView text = new TextView(getActivity());
    text.setGravity(Gravity.CENTER);
    text.setText(getString(contentResourceId));
    text.setTextSize(10 * getResources().getDisplayMetrics().density);
    int padding = (int) getResources().getDimensionPixelSize(R.dimen.activity_intro_margin);
    text.setPadding(padding, padding, padding, padding);
    ImageView image = new ImageView(getActivity());
    image.setImageResource(imageResourceId);
    LinearLayout layout = new LinearLayout(getActivity());
    layout.setOrientation(LinearLayout.VERTICAL);
    if (CommonUtils.isFroyoOrHigher()) {
        layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    } else {
        layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    }
    layout.setGravity(Gravity.CENTER);
    layout.addView(image);
    layout.addView(text);
    return layout;
}
Also used : LayoutParams(android.widget.LinearLayout.LayoutParams) TextView(android.widget.TextView) ImageView(android.widget.ImageView) LinearLayout(android.widget.LinearLayout)

Example 60 with LayoutParams

use of android.widget.LinearLayout.LayoutParams in project platform_frameworks_base by android.

the class LinearLayoutTest method create.

public ViewGroup create(Context context) {
    LinearLayout container = new LinearLayout(context);
    container.setOrientation(LinearLayout.VERTICAL);
    for (int i = 0; i < VERTICAL_ALIGNMENTS.length; i++) {
        int va = VERTICAL_ALIGNMENTS[i];
        for (int j = 0; j < HORIZONTAL_ALIGNMENTS.length; j++) {
            int ha = HORIZONTAL_ALIGNMENTS[j];
            LayoutParams lp = new LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
            lp.gravity = va | ha;
            View v = create(context, VERTICAL_NAMES[i] + "-" + HORIZONTAL_NAMES[j], 20);
            container.addView(v, lp);
        }
    }
    return container;
}
Also used : LayoutParams(android.widget.LinearLayout.LayoutParams) View(android.view.View) LinearLayout(android.widget.LinearLayout)

Aggregations

LayoutParams (android.widget.LinearLayout.LayoutParams)78 LinearLayout (android.widget.LinearLayout)44 View (android.view.View)36 TextView (android.widget.TextView)24 ImageView (android.widget.ImageView)17 Button (android.widget.Button)16 ProgressBar (android.widget.ProgressBar)9 Message (android.os.Message)8 OnClickListener (android.view.View.OnClickListener)8 ScrollView (android.widget.ScrollView)7 Handler (android.os.Handler)6 ViewGroup (android.view.ViewGroup)6 WebView (android.webkit.WebView)6 HorizontalScrollView (android.widget.HorizontalScrollView)5 ChangeBounds (android.transition.ChangeBounds)4 Crossfade (android.transition.Crossfade)4 Scene (android.transition.Scene)4 TransitionSet (android.transition.TransitionSet)4 SurfaceView (android.view.SurfaceView)4 TextureView (android.view.TextureView)4