AndroidImageSlider icon indicating copy to clipboard operation
AndroidImageSlider copied to clipboard

SliderLayout aspect ratio

Open mus9876 opened this issue 6 years ago • 1 comments

I have made a custom sliderLayout in order to get the wanted aspect ratio, but unfortunately, the image will disappear completely.

my code:-

public class CustomSliderLayout extends SliderLayout {

public CustomSliderLayout(Context context) {
    super(context);
}
public CustomSliderLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
}

public CustomSliderLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
}

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    int width = getDefaultSize(getSuggestedMinimumWidth(), widthMeasureSpec);
    int height = (int) (width / 1.65);
    setMeasuredDimension(width, height);
}

}

2019-04-04_145740

mus9876 avatar Apr 04 '19 11:04 mus9876

you can use app:layout_constraintDimensionRatio and use constraint layout as parent of slider layout. Screenshot 2021-02-20 011720

kencana16 avatar Feb 19 '21 18:02 kencana16