use of android.view.TextureView in project android_frameworks_base by crdroidandroid.
the class SingleFrameTextureViewTestActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView preview = new TextView(this);
preview.setText("This is a preview");
preview.setBackgroundColor(Color.WHITE);
mPreview = preview;
mTextureView = new TextureView(this);
mTextureView.setSurfaceTextureListener(this);
FrameLayout content = new FrameLayout(this);
content.addView(mTextureView, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
content.addView(mPreview, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
setContentView(content);
}
use of android.view.TextureView in project android_frameworks_base by crdroidandroid.
the class GetBitmapActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FrameLayout content = new FrameLayout(this);
mTextureView = new TextureView(this);
mTextureView.setSurfaceTextureListener(this);
Button button = new Button(this);
button.setText("Copy bitmap to /sdcard/textureview.png");
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Bitmap b = mTextureView.getBitmap();
try {
FileOutputStream out = new FileOutputStream(Environment.getExternalStorageDirectory() + "/textureview.png");
try {
b.compress(Bitmap.CompressFormat.PNG, 100, out);
} finally {
try {
out.close();
} catch (IOException e) {
// Ignore
}
}
} catch (FileNotFoundException e) {
// Ignore
}
}
});
content.addView(mTextureView, new FrameLayout.LayoutParams(500, 400, Gravity.CENTER));
content.addView(button, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM));
setContentView(content);
}
use of android.view.TextureView in project android_frameworks_base by crdroidandroid.
the class HardwareCanvasTextureViewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FrameLayout content = new FrameLayout(this);
mTextureView = new TextureView(this);
mTextureView.setSurfaceTextureListener(this);
mTextureView.setOpaque(false);
content.addView(mTextureView, new FrameLayout.LayoutParams(500, 500, Gravity.CENTER));
setContentView(content);
}
use of android.view.TextureView in project android_frameworks_base by crdroidandroid.
the class TextureViewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mContent = new FrameLayout(this);
mTextureView = new TextureView(this);
mTextureView.setSurfaceTextureListener(this);
mTextureView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Bitmap b = mTextureView.getBitmap(800, 800);
BufferedOutputStream out = null;
try {
File dump = new File(Environment.getExternalStorageDirectory(), "out.png");
out = new BufferedOutputStream(new FileOutputStream(dump));
b.compress(Bitmap.CompressFormat.PNG, 100, out);
} catch (FileNotFoundException e) {
e.printStackTrace();
} finally {
if (out != null)
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
});
Button button = new Button(this);
button.setText("Remove/Add");
button.setOnClickListener(new View.OnClickListener() {
private boolean mAdded = true;
@Override
public void onClick(View v) {
if (mAdded) {
mContent.removeView(mTextureView);
} else {
mContent.addView(mTextureView);
}
mAdded = !mAdded;
}
});
mContent.addView(mTextureView, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER));
mContent.addView(button, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM));
setContentView(mContent);
}
Aggregations