In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, I would like to share with you the relevant knowledge points about how to use Android's Facebook framework. The content is detailed and the logic is clear. I believe most people still know too much about this, so share this article for your reference. I hope you can get something after reading this article.
1. Configure the environment
Since I'm using android studio, I'm just going to talk about how to configure it under android studio. In powerful gradle, it only takes one sentence to get it done. Gradle will help you download this Fresco framework. Gradle is so nice that you can automatically maintain the framework in your project.
Compile 'com.facebook.fresco:fresco:0.5.0+'
two。 Start using Fresco
Because what I am loading here is a network picture, so I want to get network permission.
Initialize Fresco. If Fresco is used in many places in the project, initialize it directly in application. If I am just writing for fun, I will ok directly in front of setContentView () in activity.
Fresco.initialize (context)
To use other people's framework, you have to follow other people's requirements, yes or no, so control names and namespaces have to listen to others.
Of course, you can not write its namespace, add it when using the attributes in it, don't make trouble for yourself if you don't use it, just kill it and give it to the control uri and ok it.
Uri uri = Uri.parse ("http://pic1.nipic.com/2008-09-08/200898163242920_2.jpg");
ImageView.setImageURI (uri)
Ok, the rest of the image download, cache, image removal will be left to Fresco, is not very powerful, but here is a problem, your control size must be determined, you can not use wrap_content directly, of course, you can also set a value of width and high school, but to set the aspect ratio
ImageView.setAspectRatio (1.0f)
Of course, as mentioned above, it is powerful, not only loading web pictures, but also supporting local, Content Provider,asset,res pictures.
Local: file:// Content provider:content:// asset: asset:// res: res://, is to let you spell a uri
Of course, the SimpleDraweeView mentioned above is only one of the controls of Drawee, there is no special need to use it is enough, the following paste some of its properties, easy to find when eating
A brief introduction to the above properties:
PlaceholderImage is the so-called booth map, and that's what you see before the picture is loaded.
FailureIamge knows what it is when he sees the name, and that's the picture that is displayed when the image fails to load.
The retryImage image will be displayed when it fails to load, prompting the user to click reload, and the failureImage image will be displayed only when it has not been loaded for 4 times.
ProgressBarImage progress bar picture
BackgroundImage background picture. The background picture here is drawn first.
OverlayImage sets overlay image. Only one overlay image can be set in xml. If you need more than one image, you need to set it in java code.
PressedStateOverlayImage sets the overlay image in the clicked state, which cannot be scaled.
ImageScaleType, this is a variety of picture zoom styles, center,centerCrop,fouseCrop,centerInside,fitCenter,fitStart,fitEnd,fitXY.
These are all the contents of the article "how to use Android's Facebook Framework". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.