Back to project page markj.
The source code is released under:
GNU Lesser General Public License
If you think the Android project markj listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/** * /* w w w . j a v a2s . c o m*/ */ package com.markjmind.mobile.api.android.ui.graph; import android.content.Context; import android.util.AttributeSet; import android.widget.LinearLayout; /** * ? ???? ???? ?????? ???? ????? * ? ??????? ?????? BarElement????? * @author ??? * */ public class BarElement extends LinearLayout{ public LayoutParams barParam; public BarElement(Context context) { super(context); } public BarElement(Context context, AttributeSet attrs) { super(context,attrs); } /** * BarElement ??? * @param figure ?? * @param barColor ??? */ public void init(int figure, int barColor){ barParam = new LayoutParams(LayoutParams.MATCH_PARENT, 0); barParam.weight = figure; this.setLayoutParams(barParam); setBackgroundColor(barColor); } /** * BarElement??? ??? ???? * @return ?? */ public int getFigure(){ return (int)barParam.weight; } /** * BarElement??? ??? ???? * @param figure ?? */ public BarElement setFigure(int figure){ LinearLayout barMain = (LinearLayout)getParent(); if(barMain!=null){ LayoutParams barMainParam=(LayoutParams)barMain.getLayoutParams(); int totalFigure = (int)barMain.getWeightSum(); if(totalFigure<0){ totalFigure=0; } totalFigure = totalFigure+figure; barMain.setWeightSum(totalFigure); barMainParam.weight=totalFigure; } barParam.weight = figure; return this; } }