2014-10-04 20:55:28 -07:00
|
|
|
package org.kde.kdeconnect.UserInterface;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.res.TypedArray;
|
|
|
|
import android.util.AttributeSet;
|
|
|
|
import android.widget.ImageButton;
|
|
|
|
import android.widget.LinearLayout;
|
|
|
|
|
2014-10-04 21:07:57 -07:00
|
|
|
import org.kde.kdeconnect_tp.R;
|
|
|
|
|
2014-10-04 20:55:28 -07:00
|
|
|
public class MaxWidthImageButton extends ImageButton {
|
|
|
|
|
2014-10-04 21:07:57 -07:00
|
|
|
int mMaxWidth = Integer.MAX_VALUE;
|
|
|
|
|
2014-10-04 20:55:28 -07:00
|
|
|
public MaxWidthImageButton(Context context) {
|
|
|
|
|
|
|
|
super(context);
|
|
|
|
}
|
|
|
|
|
|
|
|
public MaxWidthImageButton(Context context, AttributeSet attrs) {
|
|
|
|
super(context, attrs);
|
2014-10-04 21:07:57 -07:00
|
|
|
|
|
|
|
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.MaxWidthImageButton);
|
|
|
|
mMaxWidth = a.getDimensionPixelSize(R.styleable.MaxWidthImageButton_maxWidth, Integer.MAX_VALUE);
|
2014-10-04 20:55:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
|
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
2014-10-04 21:07:57 -07:00
|
|
|
if(getMeasuredWidth() > mMaxWidth){
|
|
|
|
setMeasuredDimension(mMaxWidth, getMeasuredHeight());
|
2014-10-04 20:55:28 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|