本文整理汇总了Java中android.widget.LinearLayout.draw方法的典型用法代码示例。如果您正苦于以下问题:Java LinearLayout.draw方法的具体用法?Java LinearLayout.draw怎么用?Java LinearLayout.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.LinearLayout
的用法示例。
在下文中一共展示了LinearLayout.draw方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBitmapFromView
import android.widget.LinearLayout; //导入方法依赖的package包/类
public Bitmap getBitmapFromView(String title, int dotBg) {
LinearLayout llmarker = (LinearLayout) findViewById(R.id.ll_marker);
TextView markerImageView = (TextView) findViewById(R.id.tv_title);
markerImageView.setText(title);
View dot = (View) findViewById(R.id.dot_marker);
dot.setBackgroundResource(dotBg);
llmarker.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
Bitmap bitmap = Bitmap.createBitmap(llmarker.getMeasuredWidth(), llmarker.getMeasuredHeight(),
Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
llmarker.layout(0, 0, llmarker.getMeasuredWidth(), llmarker.getMeasuredHeight());
llmarker.draw(canvas);
return bitmap;
}
示例2: getBitmapByView
import android.widget.LinearLayout; //导入方法依赖的package包/类
public static Bitmap getBitmapByView(LinearLayout linearLayout) {
int h = 0;
int i = 0;
while (i < linearLayout.getChildCount()) {
try {
if (linearLayout.getChildAt(i).getVisibility() == 0) {
h += linearLayout.getChildAt(i).getHeight();
}
i++;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
Bitmap bitmap = Bitmap.createBitmap(linearLayout.getWidth(), h, Config.ARGB_8888);
linearLayout.draw(new Canvas(bitmap));
return bitmap;
}
示例3: write
import android.widget.LinearLayout; //导入方法依赖的package包/类
public void write(FormulaListView formulaListView, Bitmap.CompressFormat format) throws Exception
{
final LinearLayout f = formulaListView.getList();
Bitmap bitmap = null;
try
{
bitmap = Bitmap.createBitmap(f.getMeasuredWidth(), f.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
final Canvas canvas = new Canvas(bitmap);
f.setBackgroundColor(CompatUtils.getThemeColorAttr(f.getContext(), android.R.attr.windowBackground));
f.draw(canvas);
}
catch (OutOfMemoryError e)
{
throw new Exception(e.getLocalizedMessage());
}
finally
{
f.setBackgroundResource(android.R.color.transparent);
}
bitmap.compress(format, 100, stream);
stream.flush();
}