android TabLayout set icon from server

前端 未结 1 729
你的背包
你的背包 2021-01-26 12:40

can i set icon from server on TabLayout using Picasso library

private string path = \"192.168.0.102/project/a.png\";

TabLayout tabLayo         


        
相关标签:
1条回答
  • 2021-01-26 12:51

    You can add a tab item with a custom view. Look at this.

    See the following example:

    private View createTabItemView(String imgUri) {
        ImageView imageView = new ImageView(this);
        TabLayout.LayoutParams params = new TabLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        imageView.setLayoutParams(params);
        Picasso.get.load(imgUri).into(imageView);
        return imageView;
    }
    

    Now, you can add tab items with a custom view.

    tabLayout.addTab(tabLayout.newTab().setCustomView(createTabItemView("image URL")));
    
    0 讨论(0)
提交回复
热议问题