Skip to content

Commit 5d1f11d

Browse files
adampAndroid (Google) Code Review
authored andcommitted
Merge "Fix MediaRouteActionProvider button sizing"
2 parents ad6565d + 8c1b02e commit 5d1f11d

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

core/java/android/app/MediaRouteActionProvider.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import android.view.ActionProvider;
2727
import android.view.MenuItem;
2828
import android.view.View;
29+
import android.view.ViewGroup;
2930

3031
import java.lang.ref.WeakReference;
3132

@@ -82,6 +83,8 @@ public View onCreateActionView(MenuItem item) {
8283
mView = new MediaRouteButton(mContext);
8384
mView.setRouteTypes(mRouteTypes);
8485
mView.setExtendedSettingsClickListener(mExtendedSettingsListener);
86+
mView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
87+
ViewGroup.LayoutParams.MATCH_PARENT));
8588
return mView;
8689
}
8790

core/java/com/android/internal/view/menu/ActionMenuView.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,8 +489,10 @@ public LayoutParams generateLayoutParams(AttributeSet attrs) {
489489

490490
@Override
491491
protected LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) {
492-
if (p instanceof LayoutParams) {
493-
LayoutParams result = new LayoutParams((LayoutParams) p);
492+
if (p != null) {
493+
final LayoutParams result = p instanceof LayoutParams
494+
? new LayoutParams((LayoutParams) p)
495+
: new LayoutParams(p);
494496
if (result.gravity <= Gravity.NO_GRAVITY) {
495497
result.gravity = Gravity.CENTER_VERTICAL;
496498
}
@@ -563,6 +565,10 @@ public LayoutParams(Context c, AttributeSet attrs) {
563565
super(c, attrs);
564566
}
565567

568+
public LayoutParams(ViewGroup.LayoutParams other) {
569+
super(other);
570+
}
571+
566572
public LayoutParams(LayoutParams other) {
567573
super((LinearLayout.LayoutParams) other);
568574
isOverflowButton = other.isOverflowButton;

0 commit comments

Comments
 (0)