Good, I am trying to design a user profile screen and I want the profile image to be circular. The original image in the drawable folder is square, so the idea is to modify it in the .java. My problem is that if I change the image and it becomes circular but it is superimposed on the original square image, so that at the end the circular remains on the square. My code is as follows: (I think it may be because I modified the image once the fragment was created, but I do not know how to do it before creating the fragment)
public ProfileFragment() {
// Required empty public constructor
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_profile, container, false);
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
ImageView imageView = (ImageView) view.findViewById(R.id.perfilId);
Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.perfil);
RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(),bitmap);
roundedBitmapDrawable.setCircular(true);
imageView.setImageDrawable(roundedBitmapDrawable);
Button logout = view.findViewById(R.id.logout);
TextView name = view.findViewById(R.id.name);
name.setText(User.currentUser().getName());
logout.setOnClickListener(this);
}