florent37 / ViewTooltip

A fluent tooltip for Android
Apache License 2.0
1.08k stars 131 forks source link

Add Margin to the Tooltip #80

Open rahulagrawal13 opened 5 years ago

rahulagrawal13 commented 5 years ago

Hi, I need to set the give margin to the complete tooltip. Using padding is shifting the content inside the view. Currently the Tooltip is taking up the complete width of the screen.

Phocacius commented 4 years ago

A workaround for applying margins while there's no api method:

ViewTooltip
    .onDisplay(view -> {
        ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
        params.leftMargin = getResources().getDimensionPixelSize(R.dimen.padding_main);
        params.rightMargin = getResources().getDimensionPixelSize(R.dimen.padding_main);
        view.setLayoutParams(params);
    })