Skip to content Skip to sidebar Skip to footer

Android Tablayout Set Icon From Server

can i set icon from server on TabLayout using Picasso library private string path = '192.168.0.102/project/a.png'; TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs); tabLa

Solution 1:

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

See the following example:

private View createTabItemView(String imgUri) {
    ImageViewimageView=newImageView(this);
    TabLayout.LayoutParamsparams=newTabLayout.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")));

Post a Comment for "Android Tablayout Set Icon From Server"