Skip to content

Commit 8c1b02e

Browse files
committed
Fix MediaRouteActionProvider button sizing
Bug 6768999 Use proper layout height for MediaRouteButtons generated from MediaRouteActionProvider. Update ActionMenuView's LayoutParams handling to correctly propagate width/height values if the supplied LayoutParams is of a different type. Change-Id: I1e1b250d873869ca27f59ffb06ccf2299d57b40d
1 parent 41a48e4 commit 8c1b02e

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)