Android Open Source - android-utils Proportional Linear Layout






From Project

Back to project page android-utils.

License

The source code is released under:

Apache License

If you think the Android project android-utils 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 com.omegar.android.utils.components;
/*  w ww. j  av  a  2  s .  c om*/
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.LinearLayout;

import com.omegar.android.utils.R;

public class ProportionalLinearLayout extends LinearLayout {
  private float propotions = 1f;

  public ProportionalLinearLayout(Context context) {
    super(context);
  }

  public ProportionalLinearLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray a = context.getTheme().obtainStyledAttributes(attrs,
        R.styleable.ProportionalLinearLayout, 0, 0);

    try {
      propotions = a.getFloat(
          R.styleable.ProportionalLinearLayout_propotions, 1f);
    } finally {
      a.recycle();
    }
  }

  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int width = getDefaultSize(getSuggestedMinimumWidth(), widthMeasureSpec);
    int height = (int) (width * propotions);
    super.onMeasure(widthMeasureSpec,
        MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
  }

  @Override
  protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(w, (int) (w * propotions), oldw, oldh);
  }
}




Java Source Code List

com.omegar.android.utils.BaseDialog.java
com.omegar.android.utils.Logger.java
com.omegar.android.utils.PhotoHelper.java
com.omegar.android.utils.components.DividedLinearLayout.java
com.omegar.android.utils.components.NetworkImageView.java
com.omegar.android.utils.components.NonScrollableGridView.java
com.omegar.android.utils.components.NonScrollableListView.java
com.omegar.android.utils.components.ProportionalLinearLayout.java
com.omegar.android.utils.components.UnderlineTextView.java