Comments (3)
sorry for my english and hope u can understand
from litho.
Hi @philadelphia ! Can you please share a code that uses FrescoImage and screenshots of the wrong UI with images?
from litho.
Now i use FrescoImage to load a network image resource (i use uri of a local image in this demo) when i set cornerRadius and FrescoImage's scaleType to any type except CENTER_CROP,FIT_XY,FOCUS_CROP, and i get something wrong .if i remove cornerRadius and everything is OK . I have noticed the comment of RoundingParams.BITMAP_ONLY
as the default roundingMethod.But i wanna get these two features together(radius and other scaleType eg: CenterInside).how to do?
package com.example.lithodemo.ui;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.example.lithodemo.databinding.ActivityMainBinding;
import com.facebook.drawee.backends.pipeline.DraweeConfig;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.drawable.ScalingUtils;
import com.facebook.drawee.generic.RoundingParams;
import com.facebook.imagepipeline.core.ImagePipelineConfig;
import com.facebook.litho.ComponentContext;
import com.facebook.litho.LithoView;
import com.facebook.litho.fresco.FrescoImage;
public class MainActivity extends AppCompatActivity {
private static final String RESOURCE_PATH_DRAWABLE = "drawable";
private static final String RESOURCE_PATH_MIPMAP = "mipmap";
private static final String RESOURCE_PATH_RAW = "raw";
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityMainBinding binding = ActivityMainBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
ComponentContext componentContext = new ComponentContext(this);
ImagePipelineConfig imagePipelineConfig = ImagePipelineConfig.newBuilder(this).build();
DraweeConfig draweeConfig = DraweeConfig.newBuilder()
.build();
Fresco.initialize(this, imagePipelineConfig, draweeConfig);
int resId = getResourceId(componentContext.getAndroidContext(), "ic_tomcat");
String uri = Uri.parse("res://" + componentContext.getAndroidContext().getPackageName() + "/" + resId).toString();
FrescoImage.Builder builder = FrescoImage.create(componentContext)
.widthDip(100)
.heightDip(100)
.controller(Fresco.newDraweeControllerBuilder().setUri(uri).build());
builder.actualImageScaleType(ScalingUtils.ScaleType.CENTER_INSIDE);
RoundingParams roundingParams = new RoundingParams();
roundingParams.setCornersRadius(40);
builder.roundingParams(roundingParams);
LithoView lithoView = LithoView.create(componentContext, builder.build());
binding.llViewGroup1.addView(lithoView);
FrescoImage.Builder builder2 = FrescoImage.create(componentContext)
.widthDip(100)
.heightDip(100)
.controller(Fresco.newDraweeControllerBuilder().setUri(uri).build());
builder2.actualImageScaleType(ScalingUtils.ScaleType.CENTER_INSIDE);
RoundingParams roundingParams2 = new RoundingParams();
builder2.roundingParams(roundingParams2);
LithoView lithoView2 = LithoView.create(componentContext, builder2.build());
binding.llViewGroup2.addView(lithoView2);
}
/**
* get resource id by resource name
*
* @param context
* @param resName
* @return resId
*/
public int getResourceId(Context context, String resName) {
int resId = context.getResources().getIdentifier(resName, RESOURCE_PATH_DRAWABLE, context.getPackageName());
if (resId == 0) {
resId = context.getResources().getIdentifier(resName, RESOURCE_PATH_MIPMAP, context.getPackageName());
}
if (resId == 0) {
resId = context.getResources().getIdentifier(resName, RESOURCE_PATH_RAW, context.getPackageName());
}
return resId;
}
}
from litho.
Related Issues (20)
- LithoView update delay HOT 3
- Issue when using litho testing HOT 1
- Paint Flags support HOT 1
- ClickEvent beyond recycler HOT 4
- TextInput with RTL makes ViewPager jump between pages HOT 1
- Elements outside the viewport are not drawn on entering HOT 2
- Litho HOT 1
- Automirrored vector drawables do not get mirrored when layout is RTL HOT 2
- HorizontalScroll should provide the ability to fade edges HOT 3
- how do you update state from a Android Fragment/View parent? like React's useImperativeHandle
- Are there any plans to replace unsupported APIs (KEYCODE_BACK and #onBackPressed) to support Android's new Predictive back gesture?
- OnUpdateState not invoke on parent recycler component
- How to update prop value of MountSpec from LayoutSpec
- How does Litho (Kotlin API) compare to Compose? HOT 1
- Lazy list not working in project getting error HOT 4
- ContentAllocator API not working HOT 14
- NullPointerException in TextDrawable.Draw, seemingly from a race condition in ComponentHost$InterleavedDispatchDraw
- Setting a background to a container using Style.background(dynamicValue: DynamicDrawable) draws outside of bounds of parent. HOT 1
- Dimension error when adding flexure process
- Unable to import Litho KComponent, ComponentScope and other Litho classes HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from litho.