Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SliderLayout aspect ratio #410

Open
mus9876 opened this issue Apr 4, 2019 · 1 comment
Open

SliderLayout aspect ratio #410

mus9876 opened this issue Apr 4, 2019 · 1 comment

Comments

@mus9876
Copy link

mus9876 commented Apr 4, 2019

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

@kencana16
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants