我想让Canvas区域透明,因为我想在它后面添加一个Image,以便Canvas动作发生在图像上方.我的画布代码在这里
public class Panel extends SurfaceView implements SurfaceHolder.Callback {
private ViewThread mThread;
private ArrayList<Element> mElements = new ArrayList<Element>();
public Panel(Context context, AttributeSet attrs) {
super(context, attrs);
getHolder().addCallback(this);
mThread = new ViewThread(this);
}
public void doDraw(Canvas canvas) {
canvas.drawColor(Color.TRANSPARENT);
synchronized (mElements) {
for (Element element : mElements) {
element.doDraw(canvas);
}
}
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
// TODO Auto-generated method stub
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
if (!mThread.isAlive()) {
mThread = …Run Code Online (Sandbox Code Playgroud) 我希望有一个活动,包括一个关闭按钮,即右上角的'x'关闭活动.任何关于此的例子都会非常有用.
我想将按钮myButton添加到TextView.如何将它放在一行中,使其看起来像一组线.以下是要添加的文本示例
请在此处按此按钮刷新值集.
我希望将"here"作为可点击按钮.我该怎么做.它上面的任何片段都会有所帮助.
我想在我的Android应用程序中添加一个凹凸功能,但由于它现在只获得了妈妈,我无法获得适当的实现模式.有关它的专业知识,请帮助我提出宝贵的建议.谢谢
我想获取Android设备中当前位置的邮政编码,用于我的应用,任何关于定位它的示例或代码段.我尝试过地理编码器,它只提供lat和long位置.
我想在屏幕上绘制某些内容后清除画布的内容。
如何完全清除屏幕?上面的任何代码片段都会有所帮助。
谢谢。
这是我的代码:
public class Panel extends SurfaceView implements SurfaceHolder.Callback {
private ViewThread mThread;
private ArrayList<Element> mElements = new ArrayList<Element>();
public Panel(Context context, AttributeSet attrs) {
super(context, attrs);
this.setBackgroundColor(Color.TRANSPARENT);
this.setZOrderOnTop(true); //necessary
getHolder().setFormat(PixelFormat.TRANSPARENT);
getHolder().addCallback(this);
mThread = new ViewThread(this);
}
public void doDraw(Canvas canvas) {
super.onDraw(canvas);
//canvas.drawColor(Color.TRANSPARENT);
// canvas.drawColor(Color.argb(0, 255, 255, 255));
//canvas.drawColor(Color.rgb(-1, -1, -1));
//canvas.drawARGB(0, 255, 255, 255);
synchronized (mElements) {
for (Element element : mElements) {
element.doDraw(canvas);
}
}
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, …Run Code Online (Sandbox Code Playgroud) 我想创建5-6个类,我在第一个类中将值存储在hashmap中,我想从第4,第5和第6类调用它.如何获得这个任何片段或示例来实现这将是有帮助的,谢谢
在phonegap中安装android平台时出错,设置了npm config set proxy http:// proxydomain:port /和npm config set registry http://registry.npmjs.org/.在env变量中检查了android路径源.请允许我如何解决它.谢谢.
C:\ cordovaTest> cordova平台添加android
npm http GET https://registry.npmjs.org/cordova-android/3.7.1 TypeError:请求路径包含未转义的字符.在TunnelingAgent.exports.request(http:js:49:10)的新ClientRequest(_http_client.js:73:11)处于TunnelingAgent.createSocket(C:\ Program Files \nodejs \node_modules\cordova \node_modules\cordova-lib \node_modules \npm \node_modules\request \node_modules\tun nel-agent\index.js:117:25)在TunnelingAgent.createSecureSocket [as createSocket](C:\ Program Files \nod ejs \node_modules\cordova \node_modules\cordova-lib在TunnelingAgent.addRequest上的\node_modules \npm \node_modules\request \node_modules\tunnel-agent\index.js:184:41)(C:\ Program Files \nodejs \node_modules\cordova \n ode_modules\cordova-lib \node_modules \npm \node_modules\request \node_modules\tunne l-agent\index.js:80:8)在Object.exports.request(http.js:49:10)的新ClientRequest(_http_client.js:154:16)处. request.start中的exports.request(https.js:136:15)(C:\ Program Files \nodejs \node_modules\cordova \node_modules\cordova-lib \node_modules \npm \node_modules\request\index.js:594:30 )在Request.end(C:\ Program Files \nodejs \node_modules\c ordova \node_modules\co rdova-lib \node_modules \npm \node_modules\request\index.js:1186:28)
我想要检测给定的设备是否是Android中的平板电脑或手机.我已经在模拟器中尝试了这两个但没有工作.两者都在这里:
第一
if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE)
{
//code
}
Run Code Online (Sandbox Code Playgroud)
第二
private boolean isTabletDevice()
{
if (android.os.Build.VERSION.SDK_INT >= 11)
{
// honeycomb
// test screen size, use reflection because isLayoutSizeAtLeast is only available since 11
Configuration con = getResources().getConfiguration();
try {
Method mIsLayoutSizeAtLeast = con.getClass().getMethod("isLayoutSizeAtLeast");
Boolean r = (Boolean) mIsLayoutSizeAtLeast.invoke(con, 0x00000004); // Configuration.SCREENLAYOUT_SIZE_XLARGE
return r;
} catch (Exception x)
{
return false;
}
}
return false;
}
Run Code Online (Sandbox Code Playgroud) 我能够在正常活动中获得屏幕大小,但我需要在画布视图中获取屏幕大小并按照它进行操作.它上面的任何片段都会有所帮助.谢谢.