private void postToWall(String msg) {
Bundle parameters = new Bundle();
// parameters.putString("method", "stream.publish");
JSONObject attachment = new JSONObject();
try {
byte[] data = null;
Bitmap bi = BitmapFactory.decodeResource(getResources(),
R.drawable.bluerib);
// Bitmap bi =
// BitmapFactory.decodeFile("http://demos.com/LangGuage/medal_1.png");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bi.compress(Bitmap.CompressFormat.JPEG, 30, baos);
data = baos.toByteArray();
// Bundle params = new Bundle();
// params.putByteArray("picture", data);
attachment.put("type", "image");
// attachment.put("picture", data);
attachment.put("name", "LangGuage");
attachment.put("message", msg);
attachment.put("src", "http://demos.com/LangGuage/medal_1.png");
attachment.put("href", "http://www.abc.com");
// attachment.put("href",
// "http://hwsdemos.com/LangGuage/medal_1.png");
parameters.putString(Facebook.TOKEN, facebook.getAccessToken());
parameters.putString("attachment", attachment.toString());
String response = facebook.request("me/photos", …
Run Code Online (Sandbox Code Playgroud) 给出了两个图像,我把第一个图像称为帧图像,第二个图像作为帧图像.这里是fst是我的线性布局,我将帧图像设置为它的背景图像.现在我想在我的帧图像的白色区域填充图案图像.框架图像的外部区域是透明的,内部区域是白色的.如何在我的帧 - 图像中填充图案图像.我试过这段代码.
private void patternFill(Bitmap tempBitmapColor) {
Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.pattern_a);
BitmapDrawable bitmapDrawable = new BitmapDrawable(bmp);
bitmapDrawable.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
fst.setBackgroundDrawable(bitmapDrawable);
}
Run Code Online (Sandbox Code Playgroud)
但这是一个方形位图Image.我的Imageview就像这样,我想填充模式.
图案图像是这样的 -
我想仅在此图像的白色区域填充图案图像.我可以填充此图像框内的颜色,但在图案图像的情况下不能.任何人都可以帮助我...
更新: - 我读过如果我们想要设置多个颜色,那么我们应该使用着色器更新当前代码
public void setPattern(String newPattern){
postInvalidate();
//get pattern
int patternID = getResources().getIdentifier(newPattern, "drawable", "com.akanksha.partternfillexperiment");
//decode
Bitmap patternBMP = BitmapFactory.decodeResource(getResources(), patternID);
//create shader
BitmapShader patternBMPshader = new BitmapShader(patternBMP,
Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
//color and shader
// drawPaint.setColor(0xFFFFFFFF);
drawPaint.setShader(patternBMPshader);
patternset=true;
}
Run Code Online (Sandbox Code Playgroud)
所以,在这里我可以成功设置着色器.在这个方法之后OnDraw方法会调用
@Override
protected void onDraw(Canvas canvas) {
if(patternset){
for (int x = 0; x < …
Run Code Online (Sandbox Code Playgroud) 这是我放在我的drawable文件夹中的shape_two文件.
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="#00FFFFFF" />
<stroke
android:width="3dp"
android:color="#00ff00" />
</shape>
Run Code Online (Sandbox Code Playgroud)
这是我绘制形状的代码
private void drawLayer(ImageView tempView, Drawable drble, int wherecall) {
Drawable drawableRes = getResources()
.getDrawable(R.drawable.shape_two);// loadDrawable(R.drawable.shape_two);
int h = tempView.getMeasuredHeight();
int w = tempView.getMeasuredWidth();
drawableRes.setBounds(0, 0, w, h);
Drawable[] drawableLayers = { drble, drawableRes };
ld = new LayerDrawable(drawableLayers);
if (wherecall != 3) {
tempView.setBackground(ld);
} else {
tempView.setImageDrawable(ld);
}
td = new TransitionDrawable(drawableLayers);
td.setCrossFadeEnabled(true);
}
Run Code Online (Sandbox Code Playgroud)
这里tempview是我的ImageView和drble是另一个drawable我在另一层使用.此代码没有任何错误消息正常工作.
我的问题是当我在我的ImageViews上绘制形状时,它会重新调整大小(更改高度和宽度).我有不同大小的imageView,我想使用单一形状的xml绘制边框,我的ImageView大小不应该这样做.任何人都可以告诉我如何实现它.
搜索了很多东西后我才知道我不能对它进行位图操作,根据形状重新调整大小,因为xml文件不是位图.我在某地读过这个问题可以通过使用canvas来解决但是怎么做..
更新:
我观察到,虽然更改图层onsingletap只有高度增加而不是ImageView的宽度.如果我的布局有4个ImageView,那么第一次只在不同的imageView上单击,所有imageView重新调整大小一次.之后,如果我们再次点击 - 再没有什么可以重新调整大小.我想在第一次在ImageView重新设置视图上设置图层,然后调整自己.我不知道为什么会发生这种情况.
我正在为我的所有布局应用相同的代码,对于某些布局,它的工作正常,有些则不是.
我还试过了什么.
我试过通过GradientDrawable制作边框图像
GradientDrawable gd …
Run Code Online (Sandbox Code Playgroud)我录制的视频时间有限.现在我想获取所有视频帧.我使用下面的代码,并使用它,我能够得到帧,但我没有得到所有的视频帧.重复3到4帧然后我有一个不同的帧.但是众所周知,我们可以在一秒钟内获得25-30帧来显示流畅的视频.如何获得所有帧.
for (int i = 0; i < 30; i++) {
Bitmap bArray = mediaMetadataRetriever.getFrameAtTime(
1000000 * i,
MediaMetadataRetriever.OPTION_CLOSEST);
savebitmap(bArray, 33333 * i);
}
Run Code Online (Sandbox Code Playgroud)
我不想使用NDK.我得到这个链接不知道应该是什么值"argb8888".我在这里得到错误.任何人都可以解释如何做到这一点. 从Android中的视频图像中获取帧
我正在尝试从Facebook获取用户的教育详细信息和工作描述。我成功登录并获得访问令牌。但我无法获取所需的详细信息
我正在使用的代码:-
public void getUserExpandEducation() {
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/{education-experience-id}", //"/{user_education_history}",//
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
Log.d("fb response",response.toString());
}
}
).executeAsync();
}
Run Code Online (Sandbox Code Playgroud)
谁能回答我收到错误消息(#803)您请求的某些别名不存在:{education-experience-id}