Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to remove white border around label. #22

Open
brije111 opened this issue Jul 20, 2017 · 5 comments
Open

How to remove white border around label. #22

brije111 opened this issue Jul 20, 2017 · 5 comments

Comments

@brije111
Copy link

brije111 commented Jul 20, 2017

device-2017-07-20-140742
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

@linger1216
Copy link
Owner

plz show ur code

@brije111
Copy link
Author

brije111 commented Jul 25, 2017

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);
        }
    }
}`

@xiaozhao0331
Copy link

use the lib version 1.1.0 or remove the // rectStrokePaint.setColor(strokeColor);
// rectStrokePaint.setStrokeWidth(strokeWidth);
in LabelViewHelper.

@poojakaluskar
Copy link

@brije111 Did you ever find solution for this one?

@poojakaluskar
Copy link

poojakaluskar commented Apr 16, 2018

I ended up using app:label_strokeColor="@android:color/transparent" to remove border. You can set your desire color.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants