MaterialSpinner icon indicating copy to clipboard operation
MaterialSpinner copied to clipboard

No attribute for Dropdown width?

Open Subroid opened this issue 7 years ago • 2 comments

the dropdown width is taking the whole screen. how can i control it?

image

<com.cepheuen.elegantnumberbutton.view.ElegantNumberButton android:id="@+id/elegantNumberButton" android:layout_width="84dp" android:layout_height="wrap_content" android:elevation="4dp" app:backGroundColor="#4657B8" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:textSize="6sp">

</com.cepheuen.elegantnumberbutton.view.ElegantNumberButton>

Subroid avatar Jul 27 '18 10:07 Subroid

I think that option is no implemented. I had to modify source code to get it working:

MaterialSpinner.java

  @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
//    popupWindow.setWidth(MeasureSpec.getSize(widthMeasureSpec));
    // Popup width hardcoded.
    popupWindow.setWidth(250);
    popupWindow.setHeight(calculatePopupWindowHeight());

...

  public void expand() {
    if (!hideArrow) {
      animateArrow(true);
    }
    nothingSelected = true;
    // Popup position hardcoded.
    popupWindow.showAsDropDown(this, -100, 0);
  }

enekonieto avatar Aug 15 '18 11:08 enekonieto

@subrud What is ElegantNumberButton?

I set the layout_width to 100dp to test this and the PopupWindow matched the MaterialSpinner width. @enekonieto are you sure you need to hardcode the width there?

I was thinking a fix for this would be to set the PopupWindow width when the spinner is laid out:

getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
  @Override public void onGlobalLayout() {
    spinner.getPopupWindow().setWidth(spinner.getWidth());
  }
});

However, it is working for me; I cannot reproduce this.

jaredrummler avatar Oct 29 '18 02:10 jaredrummler