Tabnine Logo
AspectRatioFrameLayout
Code IndexAdd Tabnine to your IDE (free)

How to use
AspectRatioFrameLayout
in
jsc.kit.component.widget

Best Java code snippets using jsc.kit.component.widget.AspectRatioFrameLayout (Showing top 7 results out of 315)

origin: JustinRoom/JSCKit

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  setMeasuredDimension(getDefaultSize(0, widthMeasureSpec), getDefaultSize(0, heightMeasureSpec));
  int width;
  int height;
  switch (baseWhat){
    case 0://width
      width = getMeasuredWidth();
      height = width * yAspect / xAspect;
      heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
      break;
    case 1:
      height = getMeasuredHeight();
      width = height * xAspect / yAspect;
      widthMeasureSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY);
      break;
  }
  super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
origin: JustinRoom/JSCKit

  public void setyAspect(@IntRange(from = 1) int yAspect) {
    this.yAspect = yAspect;
    requestLayout();
  }
}
origin: JustinRoom/JSCKit

@Override
public View createView(@NonNull ViewGroup parent, int viewType) {
  int radius = CompatResourceUtils.getDimensionPixelSize(parent, R.dimen.space_4);
  AspectRatioFrameLayout aspectRatioLinearLayout = new AspectRatioFrameLayout(parent.getContext());
  aspectRatioLinearLayout.setBaseWhat(0);
  aspectRatioLinearLayout.setxAspect(1);
  aspectRatioLinearLayout.setyAspect(1);
  aspectRatioLinearLayout.setPadding(12, 12, 12, 12);
  View backgroundView = new View(parent.getContext());
  backgroundView.setBackground(WindowUtils.getSelectableItemBackgroundBorderless(parent.getContext()));
  aspectRatioLinearLayout.addView(backgroundView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
  aspectRatioLinearLayout.setBackground(DynamicDrawableFactory.cornerRectangleDrawable(0xFF3F51B5, radius));
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    aspectRatioLinearLayout.setElevation(radius);
  }
  aspectRatioLinearLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0));
  return aspectRatioLinearLayout;
}
origin: JustinRoom/JSCKit

params.rightMargin = margin;
params.topMargin = margin;
AspectRatioFrameLayout frameLayout = new AspectRatioFrameLayout(this);
frameLayout.setxAspect(4);
frameLayout.setyAspect(3);
setContentView(frameLayout, params);
setTitleBarTitle(getClass().getSimpleName().replace("Activity", ""));
recyclerView.setItemAnimator(new DefaultItemAnimator());
adapter = new LayoutManagerAdapter();
frameLayout.addView(recyclerView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
recyclerView.setAdapter(adapter);
List<ClassItem> items = new ArrayList<>();
origin: JustinRoom/JSCKit

p1.gravity = Gravity.CENTER_HORIZONTAL;
p1.topMargin = 8;
tvShortName = new TextView(itemView.getContext());
tvShortName.setGravity(Gravity.CENTER);
tvShortName.setTextColor(0xFF333333);
initViewShapeProvider(tvShortName);
tvShortName.setBackgroundColor(0xFFF2F2F2);
itemView.addView(tvShortName, p1);
tvComponentName = new TextView(itemView.getContext());
tvComponentName.setTextColor(Color.WHITE);
tvComponentName.setGravity(Gravity.CENTER_HORIZONTAL|Gravity.BOTTOM);
tvComponentName.setTextSize(TypedValue.COMPLEX_UNIT_SP, 11);
tvComponentName.setLines(2);
itemView.addView(tvComponentName, p2);
p3.topMargin = 8;
p3.rightMargin = 8;
dotView = new DotView(itemView.getContext());
dotView.setShape(DotView.CIRCULAR);
dotView.setBackgroundColor(Color.RED);
itemView.addView(dotView, p3);
origin: JustinRoom/JSCKit

public void setBaseWhat(@IntRange(from = 0, to = 1) int baseWhat) {
  this.baseWhat = baseWhat;
  requestLayout();
}
origin: JustinRoom/JSCKit

public void setxAspect(@IntRange(from = 1) int xAspect) {
  this.xAspect = xAspect;
  requestLayout();
}
jsc.kit.component.widgetAspectRatioFrameLayout

Javadoc

自定义宽高比例的FrameLayout,例如2:5、4:3等等。 默认为1:1。


Email:1006368252@qq.com
QQ:1006368252
https://github.com/JustinRoom/JSCKit

Most used methods

  • <init>
  • addView
  • getContext
  • getDefaultSize
  • getMeasuredHeight
  • getMeasuredWidth
  • requestLayout
  • setBackground
  • setBaseWhat
  • setElevation
  • setLayoutParams
  • setMeasuredDimension
  • setLayoutParams,
  • setMeasuredDimension,
  • setPadding,
  • setxAspect,
  • setyAspect

Popular in Java

  • Reactive rest calls using spring rest template
  • getResourceAsStream (ClassLoader)
  • setRequestProperty (URLConnection)
  • onCreateOptionsMenu (Activity)
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now