How to remove white border around label.
Everything looks very good. I used this lib and I'm good with it. But when my boss said to remove white border around label view. I searched for any method to remove it but could not find. I stuck. Please help
plz show ur code
layout looks like this
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_marginRight="4dp"> <FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <com.lid.lib.LabelImageView android:id="@+id/icon" android:layout_width="80dp" android:layout_height="80dp" android:scaleType="centerCrop" app:label_backgroundColor="?attr/colorAccent" app:label_orientation="LEFT_TOP" app:label_text="CHINA" app:label_textSize="@dimen/text_size_tertiary" /> <!--<ImageView android:layout_width="100dp" android:layout_height="100dp" android:id="@+id/download_icon" app:srcCompat="@drawable/ic_download"/>--> </FrameLayout> <TextView android:id="@+id/text_view" android:layout_width="80dp" android:layout_height="wrap_content" android:text="theme1" android:gravity="center" android:textSize="@dimen/text_size_primary" /> </LinearLayout>
and Here is Adapter Code
`private class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder>{
private Context context;
public MyAdapter(Context context) {
this.context=context;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new ViewHolder(LayoutInflater.from(context).inflate(R.layout.theme_recycler_item,parent,false));
}
@Override
public void onBindViewHolder(ViewHolder holder, final int position) {
Glide.with(context).load(themes.get(position).getIconURL()).into(holder.icon);
holder.textView.setText(themes.get(position).getName());
if (themes.get(position).isDownloaded&&themes.get(position).isValid()) {
String str=sharedPreferences.getString(Constants.SHAREDPREF.THEME, "no_theme");
if (str.equals("no_theme")&&position==0){
holder.icon.setLabelText("Active");
holder.icon.setLabelTextColor(Color.WHITE);
holder.icon.setLabelVisual(true);
holder.icon.setLabelBackgroundColor(ContextCompat.getColor(getActivity(), R.color.green));
//holder.download_icon.setImageResource(R.drawable.ic_check_green);
} else if (themes.get(position).getName().equals(str)) {
holder.icon.setLabelText("Active");
holder.icon.setLabelTextColor(Color.WHITE);
holder.icon.setLabelVisual(true);
holder.icon.setLabelBackgroundColor(ContextCompat.getColor(getActivity(), R.color.green));
//holder.download_icon.setImageResource(R.drawable.ic_check_green);
} else {
//holder.icon.setLabelText("");
//holder.icon.setLabelTextColor(Color.TRANSPARENT);
holder.icon.setLabelVisual(false);
//holder.download_icon.setImageResource(R.drawable.ic_check);
}
} else {
holder.icon.setLabelText("buy now");
holder.icon.setLabelTextColor(Color.WHITE);
holder.icon.setLabelVisual(true);
holder.icon.setLabelBackgroundColor(ContextCompat.getColor(getActivity(), R.color.red));
//holder.download_icon.setImageResource(R.drawable.ic_download);
}
}
@Override
public int getItemCount() {
return themes.size();
}
class ViewHolder extends RecyclerView.ViewHolder{
LabelImageView icon;
TextView textView;
public ViewHolder(View itemView) {
super(itemView);
icon=(LabelImageView) itemView.findViewById(R.id.icon);
//download_icon=(ImageView) itemView.findViewById(R.id.download_icon);
textView=(TextView) itemView.findViewById(R.id.text_view);
}
}
}`
use the lib version 1.1.0 or remove the // rectStrokePaint.setColor(strokeColor); // rectStrokePaint.setStrokeWidth(strokeWidth); in LabelViewHelper.
@brije111 Did you ever find solution for this one?
I ended up using app:label_strokeColor="@android:color/transparent" to remove border. You can set your desire color.