我必须使用GridLayout我的应用程序.问题GridLayout是体重的限制因此我必须在运行时缩放其子项大小.我是在一个人的帮助下做到的OnGlobalLayoutListener.
我的孩子GridLayout是两个孩子Button,有父母的宽度和父母身高的一半.一个Button在上面,一个Button在下面.如果Button单击鞋面,我想将GridLayout宽度和高度的大小切换为500,宽度和高度的大小为700.点击在上部后Button的ButtonS的关系具有正确的尺度,但他们没有这样做.
public class HauptAktivitaet extends Activity implements OnLayoutChangeListener, OnClickListener{
/** ContentView its sizes I will change on a click later */
private GridLayout mGridLayout;
/** LayoutParams of the above child */
private GridLayout.LayoutParams mGridLayout_LayoutParams_Above;
/** LayoutParams of the below child */
private GridLayout.LayoutParams mGridLayout_LayoutParams_Below;
/** Children of the ContentView */
private Button mButtonAbove;
private Button mButtonBelow;
@Override …Run Code Online (Sandbox Code Playgroud) 我有这样的习惯View:
public class ShadowTextView extends TextView {
...
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
final int parentWidth = MeasureSpec.getSize(widthMeasureSpec);
final int parentHeight = MeasureSpec.getSize(heightMeasureSpec);
final int minSize = Math.min(parentWidth, parentHeight);
mShadow = new Paint(Paint.ANTI_ALIAS_FLAG);
RadialGradient gradient = new RadialGradient(
parentWidth * mCenterX,
parentHeight * mCenterY,
minSize * mGradientRadiusWidthPercent,
new int[]{mStartColor, mCenterColor, mEndColor},
null,
android.graphics.Shader.TileMode.CLAMP);
mShadow.setDither(true);
mShadow.setShader(gradient);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawRect(0, 0, getWidth(), getHeight(), mShadow);
}
...
}
Run Code Online (Sandbox Code Playgroud)
在XML格式中,我希望将它CustomView …