fresco icon indicating copy to clipboard operation
fresco copied to clipboard

Use XML-defined styles in a hierarchy

Open xianfeng-zhu opened this issue 11 years ago • 2 comments

I define a style like this:

<style name="AvatarSimpleDraweeViewProperties">
        <item name="packageName:actualImageScaleType">centerCrop</item>
        <item name="packageName:placeholderImage">@drawable/user_avatar_default</item>
        <item name="packageName:placeholderImageScaleType">centerCrop</item>
        <item name="packageName:failureImage">@drawable/user_avatar_default</item>
        <item name="packageName:failureImageScaleType">centerCrop</item>
        <item name="packageName:viewAspectRatio">1</item>
        <item name="packageName:roundAsCircle">true</item>
    </style>

Can I create a GenericDraweeHierarchy instance with the values inflated from this xml?

xianfeng-zhu avatar Dec 02 '15 09:12 xianfeng-zhu

Hi, you can't inflate only the hierarchy at the moment, but you can inflate GenericDraweeView. If you just need the hierarchy, you could make a pull request that extracts GenericDraweeHierarchy inflation logic out of GenericDraweeView (preferably to a separate file, GenericDraweeHierarchyInflator or similar). I wanted to do that since long time ago, but there was always something else.

plamenko avatar Dec 02 '15 15:12 plamenko

You can use GenericDraweeHierarchyInflater.inflateHierarchy(Context context, AttributeSet attrs) or GenericDraweeHierarchyInflater.inflateBuilder(Context context, AttributeSet attrs)` to get a hierarchy or a builder.

oprisnik avatar Feb 15 '17 10:02 oprisnik