Example usage for android.widget LinearLayout setVisibility

List of usage examples for android.widget LinearLayout setVisibility

Introduction

In this page you can find the example usage for android.widget LinearLayout setVisibility.

Prototype

@RemotableViewMethod
public void setVisibility(@Visibility int visibility) 

Source Link

Document

Set the visibility state of this view.

Usage

From source file:se.tmeit.app.ui.members.MemberInfoFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_member_info, container, false);

    Bundle args = getArguments();//from   ww w . j a v a 2 s . c  o  m
    TextView realNameText = (TextView) view.findViewById(R.id.member_real_name);
    realNameText.setText(args.getString(Member.Keys.REAL_NAME));

    TextView usernameText = (TextView) view.findViewById(R.id.member_username);
    usernameText.setText(args.getString(Member.Keys.USERNAME));

    TextView titleText = (TextView) view.findViewById(R.id.member_title);
    setTextWithPrefix(titleText, R.string.member_title, args.getString(Member.Keys.TITLE_TEXT));

    TextView teamText = (TextView) view.findViewById(R.id.member_team);
    setTextWithPrefix(teamText, R.string.member_team, args.getString(Member.Keys.TEAM_TEXT));

    ImageView imageView = (ImageView) view.findViewById(R.id.member_face);
    List<String> faces = args.getStringArrayList(Member.Keys.FACES);
    if (null != faces && !faces.isEmpty()) {
        mFaceHelper.picasso(faces).placeholder(R.drawable.member_placeholder).into(imageView);

        imageView.setOnClickListener(mOnImageClickedListener);
    } else {
        imageView.setImageResource(R.drawable.member_placeholder);
    }

    final String email = args.getString(Member.Keys.EMAIL);
    Button emailButton = (Button) view.findViewById(R.id.member_button_email);
    if (!TextUtils.isEmpty(email)) {
        emailButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MemberActions.sendEmailTo(email, MemberInfoFragment.this);
            }
        });
        emailButton.setEnabled(true);
    } else {
        emailButton.setEnabled(false);
    }

    final String phoneNo = args.getString(Member.Keys.PHONE);
    Button smsButton = (Button) view.findViewById(R.id.member_button_message);
    Button callButton = (Button) view.findViewById(R.id.member_button_call);

    if (!TextUtils.isEmpty(phoneNo)) {
        smsButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MemberActions.sendSmsTo(phoneNo, MemberInfoFragment.this);
            }
        });
        callButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MemberActions.makeCallTo(phoneNo, MemberInfoFragment.this);
            }
        });

        smsButton.setEnabled(true);
        callButton.setEnabled(true);
    } else {
        smsButton.setEnabled(false);
        callButton.setEnabled(false);
    }

    setTextWithPrefixIfNotEmpty(view, R.id.member_flags, R.string.member_info,
            args.getString(Member.Keys.FLAGS));
    setTextWithPrefixIfNotEmpty(view, R.id.member_prao, R.string.member_prao,
            args.getString(Member.Keys.DATE_PRAO));
    setTextWithPrefixIfNotEmpty(view, R.id.member_marskalk, R.string.member_marskalk,
            args.getString(Member.Keys.DATE_MARSKALK));
    setTextWithPrefixIfNotEmpty(view, R.id.member_vraq, R.string.member_vraq,
            args.getString(Member.Keys.DATE_VRAQ));

    int experiencePoints = args.getInt(Member.Keys.EXPERIENCE_POINTS);
    TextView experienceText = (TextView) view.findViewById(R.id.member_experience);
    if (experiencePoints >= EXPERIENCE_MIN) {
        setTextWithPrefix(experienceText, R.string.member_exp,
                String.format(getString(R.string.member_points_format), experiencePoints));
        experienceText.setVisibility(View.VISIBLE);
    } else {
        experienceText.setVisibility(View.GONE);
    }

    List<MemberBadge> experienceBadges = args.getParcelableArrayList(Member.Keys.EXPERIENCE_BADGES);
    LinearLayout badgesLayout = (LinearLayout) view.findViewById(R.id.member_badges);
    if (null != experienceBadges && !experienceBadges.isEmpty()) {
        initializeListOfBadges(badgesLayout, experienceBadges);
    } else {
        badgesLayout.setVisibility(View.GONE);
    }

    return view;
}

From source file:de.enlightened.peris.NewPost.java

private void setColor(final String color) {

    final LinearLayout llPicker = (LinearLayout) findViewById(R.id.profileColorPicker);
    llPicker.setVisibility(View.GONE);

    final String selectedText = this.bodyInputter.getText().toString()
            .substring(this.colorSelectionStart, this.colorSelectionEnd).trim();

    final String firstPart = this.bodyInputter.getText().toString().substring(0, this.colorSelectionStart);
    final String secondPart = this.bodyInputter.getText().toString().substring(this.colorSelectionEnd,
            this.bodyInputter.getText().toString().length());
    this.bodyInputter.setText(firstPart + "[color=" + color + "]" + selectedText + "[/color]" + secondPart);
    this.bodyInputter.setSelection(this.colorSelectionEnd + ("[color=" + color + "]").length());

    final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(this.bodyInputter, 0);
    this.colorPickerOpen = false;
}

From source file:at.wada811.app.fragment.ExpandableListFragment.java

/**
 * Provide default implementation to return a expandable list view. Subclasses
 * can override to replace with their own layout. If doing so, the returned
 * view hierarchy <em>must</em> have a ExpandableListView whose id
 * is {@link android.R.id#list android.R.id.list} and can optionally
 * have a sibling view id {@link android.R.id#empty android.R.id.empty} that is to be shown when
 * the list is empty./* w  w  w.j  a  va2 s  .  com*/
 * 
 * <p>
 * If you are overriding this method with your own custom content, consider including the
 * standard layout {@link android.R.layout#list_content} in your layout file, so that you
 * continue to retain all of the standard behavior of ExpandableListFragment. In particular,
 * this is currently the only way to have the built-in indeterminant progress state be shown.
 * 
 * @param inflater The LayoutInflater object that can be used to inflate any views in the
 *        fragment,
 * @param container If non-null, this is the parent view that the fragment's UI should be
 *        attached to. The fragment should not add the view itself, but this can be used to
 *        generate the LayoutParams of the view.
 * @param savedInstanceState If non-null, this fragment is being re-constructed from a previous
 *        saved state as given here.
 * @return Return the View for the fragment's UI, or null.
 */
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    final Context context = getActivity();

    final FrameLayout root = new FrameLayout(context);

    // ------------------------------------------------------------------

    final LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(LinearLayout.VERTICAL);
    pframe.setVisibility(View.GONE);
    pframe.setGravity(Gravity.CENTER);

    final ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);
    pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    final FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);

    final TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    final ExpandableListView lv = new ExpandableListView(getActivity());
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    return root;
}

From source file:com.i2max.i2smartwork.common.conference.ConferenceDetailViewFragment.java

public void setFilesLayout(String title, LinearLayout targetLayout, Object object) {

    final List<LinkedTreeMap<String, String>> filesList = (List<LinkedTreeMap<String, String>>) object;
    if (filesList == null || (filesList != null && filesList.size() <= 0)) {
        targetLayout.setVisibility(View.GONE);
    } else {/*from  w w w.j a  va2s.  com*/
        Log.e(TAG, "fileList size =" + filesList.size());
        targetLayout.setVisibility(View.VISIBLE);
        targetLayout.removeAllViews();
        //addTitleView
        LinearLayout.LayoutParams tvParam = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        tvParam.setMargins(0, DisplayUtil.dip2px(getActivity(), 12), 0, DisplayUtil.dip2px(getActivity(), 10));

        TextView tvTitle = new TextView(getActivity());
        tvTitle.setLayoutParams(tvParam);
        if (Build.VERSION.SDK_INT < 23) {
            tvTitle.setTextAppearance(getActivity(), android.R.style.TextAppearance_Material_Medium);
        } else {
            tvTitle.setTextAppearance(android.R.style.TextAppearance_Material_Medium);
        }
        tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15);
        tvTitle.setTextColor(getResources().getColor(R.color.text_color_black));
        tvTitle.setText(title);

        targetLayout.addView(tvTitle);

        //addFilesView
        for (int i = 0; i < filesList.size(); i++) {
            final LinkedTreeMap<String, String> fileMap = filesList.get(i);
            LayoutInflater inflater = (LayoutInflater) getActivity()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View fileView = inflater.inflate(R.layout.view_item_file, null);

            ImageView ivIcFileExt = (ImageView) fileView.findViewById(R.id.iv_ic_file_ext);
            TextView tvFileNm = (TextView) fileView.findViewById(R.id.tv_file_nm);

            //??  ? 
            ivIcFileExt.setImageResource(R.drawable.ic_file_doc);
            String fileNm = FormatUtil.getStringValidate(fileMap.get("file_nm"));
            tvFileNm.setText(fileNm);
            FileUtil.setFileExtIcon(ivIcFileExt, fileNm);
            final String fileExt = FileUtil.getFileExtsion(fileNm);
            final String downloadURL = I2UrlHelper.File
                    .getDownloadFile(FormatUtil.getStringValidate(fileMap.get("file_id")));

            fileView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    try {
                        Intent intent = null;
                        if ("Y".equals(FormatUtil.getStringValidate(fileMap.get("conv_yn")))) {
                            //i2viewer ? ( conv_yn='Y')
                            intent = IntentUtil.getI2ViewerIntent(
                                    FormatUtil.getStringValidate(fileMap.get("file_id")),
                                    FormatUtil.getStringValidate(fileMap.get("file_nm")));
                            getActivity().startActivity(intent);
                        } else if ("mp4".equalsIgnoreCase(fileExt) || "fla".equalsIgnoreCase(fileExt)
                                || "wmv".equalsIgnoreCase(fileExt) || "avi".equalsIgnoreCase(fileExt)) { //video
                            intent = IntentUtil.getVideoPlayIntent(downloadURL);
                        } else {
                            //? ??
                            intent = new Intent(Intent.ACTION_VIEW, Uri.parse(downloadURL));
                            Bundle bundle = new Bundle();
                            bundle.putString("Authorization", I2UrlHelper.getTokenAuthorization());
                            intent.putExtra(Browser.EXTRA_HEADERS, bundle);
                            Log.d(TAG, "intent:" + intent.toString());
                        }
                        getActivity().startActivity(intent);
                    } catch (ActivityNotFoundException e) {
                        Toast.makeText(getActivity(),
                                "I2Viewer? ?  .\n  ? ?.",
                                Toast.LENGTH_LONG).show();
                        //TODO ? ? ?   URL
                    }
                }
            });

            targetLayout.addView(fileView);
        }

    }
}

From source file:de.enlightened.peris.NewPost.java

@Override
public final boolean onKeyDown(final int keyCode, final KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        if (this.colorPickerOpen) {

            final LinearLayout llPicker = (LinearLayout) findViewById(R.id.profileColorPicker);
            llPicker.setVisibility(View.GONE);

            final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.showSoftInput(this.bodyInputter, 0);

            this.colorPickerOpen = false;
            return true;
        }/*from ww  w.  ja  v a 2  s  . c o  m*/
    }

    return super.onKeyDown(keyCode, event);
}

From source file:org.getlantern.firetweet.fragment.support.BaseSupportListFragment.java

/**
 * Provide default implementation to return a simple list view. Subclasses
 * can override to replace with their own layout. If doing so, the returned
 * view hierarchy <em>must</em> have a ListView whose id is
 * {@link android.R.id#list android.R.id.list} and can optionally have a
 * sibling view id {@link android.R.id#empty android.R.id.empty} that is to
 * be shown when the list is empty.//  ww  w.  ja  v  a 2 s  . c o  m
 * <p/>
 * <p/>
 * If you are overriding this method with your own custom content, consider
 * including the standard layout {@link android.R.layout#list_content} in
 * your layout file, so that you continue to retain all of the standard
 * behavior of ListFragment. In particular, this is currently the only way
 * to have the built-in indeterminant progress state be shown.
 */
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    final Context context = getActivity();

    final FrameLayout root = new FrameLayout(context);

    // ------------------------------------------------------------------

    final LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(LinearLayout.VERTICAL);
    pframe.setVisibility(View.GONE);
    pframe.setGravity(Gravity.CENTER);

    final ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);
    pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    final ExtendedFrameLayout lframe = new ExtendedFrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);
    lframe.setTouchInterceptor(mInternalOnTouchListener);

    final TextView tv = new TextView(getActivity());
    tv.setTextAppearance(context, ThemeUtils.getTextAppearanceLarge(context));
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    final ListView lv = new ListView(getActivity());
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lv.setOnScrollListener(this);
    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    return root;
}

From source file:dynamite.zafroshops.app.fragment.TypedZopsFragment.java

private void resetVisibility(ListView zops, LinearLayout noZops, RelativeLayout loader, boolean showLoader) {
    Activity activity = getActivity();/*from  w ww. jav  a  2 s .co m*/
    MainActivity mainActivity = (MainActivity) activity;

    if (typedZops.size() == 0 && mainActivity.Counts.get(zopType) == 0) {
        noZops.setVisibility(View.VISIBLE);
        zops.setVisibility(View.INVISIBLE);
    } else {
        noZops.setVisibility(View.INVISIBLE);
        zops.setVisibility(View.VISIBLE);
    }

    if (showLoader) {
        zops.setVisibility(View.INVISIBLE);
        noZops.setVisibility(View.INVISIBLE);
        loader.setVisibility(View.VISIBLE);
    } else {
        loader.setVisibility(View.INVISIBLE);
    }
}

From source file:com.gh4a.IssueCreateActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    setTheme(Gh4Application.THEME);/* ww w .ja  va 2 s  . c o m*/
    super.onCreate(savedInstanceState);

    mSelectedLabels = new ArrayList<Label>();
    Bundle data = getIntent().getExtras();

    mRepoOwner = data.getString(Constants.Repository.REPO_OWNER);
    mRepoName = data.getString(Constants.Repository.REPO_NAME);
    mIssueNumber = data.getInt(Constants.Issue.ISSUE_NUMBER);
    if (mIssueNumber != 0) {
        mEditMode = true;
    }

    if (!isOnline()) {
        setErrorView();
        return;
    }

    if (!isAuthorized()) {
        Intent intent = new Intent().setClass(this, Github4AndroidActivity.class);
        startActivity(intent);
        finish();
    }
    setContentView(R.layout.issue_create);

    mActionBar = getSupportActionBar();
    mActionBar.setTitle(mEditMode ? getResources().getString(R.string.issue_edit) + " #" + mIssueNumber
            : getResources().getString(R.string.issue_create));
    mActionBar.setSubtitle(mRepoOwner + "/" + mRepoName);
    mActionBar.setDisplayHomeAsUpEnabled(true);

    mEtTitle = (EditText) findViewById(R.id.et_title);
    mEtDesc = (EditText) findViewById(R.id.et_desc);

    mLinearLayoutLabels = (LinearLayout) findViewById(R.id.ll_labels);
    mTvSelectedMilestone = (EditText) findViewById(R.id.et_milestone);

    mTvSelectedAssignee = (EditText) findViewById(R.id.et_assignee);

    TextView tvIssueLabelAdd = (TextView) findViewById(R.id.tv_issue_label_add);
    tvIssueLabelAdd.setTypeface(getApplicationContext().boldCondensed);
    tvIssueLabelAdd.setTextColor(Color.parseColor("#0099cc"));

    getSupportLoaderManager().initLoader(0, null, this);
    getSupportLoaderManager().initLoader(1, null, this);
    getSupportLoaderManager().initLoader(2, null, this);
    getSupportLoaderManager().initLoader(4, null, this);

    LinearLayout ll = (LinearLayout) findViewById(R.id.for_collaborator);
    ll.setVisibility(View.GONE);

    if (mEditMode) {
        showLoading();
        getSupportLoaderManager().initLoader(3, null, this);
        getSupportLoaderManager().getLoader(3).forceLoad();
    } else {
        hideLoading();
        getSupportLoaderManager().getLoader(4).forceLoad();
    }
}

From source file:com.alexive.graphicalutils.view.CardBuilder.java

public CardView build(Context context, CardView mCardView, boolean overrideBackground,
        boolean overrideElevation, boolean overrideRadius) {
    if (!mCardView.getTag(CARD_TYPE_TAG).equals(mCardType))
        throw new IllegalArgumentException("Attempting to recycle a card of another type.");
    LinkedList<TextView> textViews = new LinkedList<>();
    View view = mCardView.findViewById(android.R.id.text1);
    if (view != null) {
        view.setTag(true);/*from  w  w  w.  j  ava 2s  .co  m*/
        textViews.add(((TextView) view));
        ((TextView) view).setText(title);
        view.setVisibility(title != null ? View.VISIBLE : View.GONE);
    }

    view = mCardView.findViewById(android.R.id.text2);
    if (view != null) {
        textViews.add(((TextView) view));
        ((TextView) view).setText(subTitle);
        view.setVisibility(subTitle != null ? View.VISIBLE : View.GONE);
    }

    view = mCardView.findViewById(R.id.content);
    if (view != null) {
        textViews.add(((TextView) view));
        ((TextView) view).setText(text);
        view.setVisibility(text != null ? View.VISIBLE : View.GONE);
    }

    mCardView.setOnClickListener(mPrimaryAction);
    //TODO add the custom view
    FrameLayout mCustomViewParent = (FrameLayout) mCardView.findViewById(R.id.custom_view_container);
    if (mCustomViewParent != null) {
        mCustomViewParent.removeAllViews();
        if (customMainView != null)
            mCustomViewParent.addView(customMainView);
    }

    view = mCardView.findViewById(android.R.id.content);
    if (view != null) {
        if (image instanceof Bitmap)
            ((ImageView) view).setImageBitmap((Bitmap) image);
        else if (image instanceof Drawable)
            ((ImageView) view).setImageDrawable((Drawable) image);
        else
            ((ImageView) view).setImageDrawable(null);
    }

    LinearLayout mActionContainer = (LinearLayout) mCardView.findViewById(R.id.action_container);
    if (actions.isEmpty())
        mActionContainer.setVisibility(View.GONE);
    else {
        mActionContainer.setVisibility(View.VISIBLE);
        for (int i = 0; i < actions.size(); i++) {
            CardAction action = actions.get(i);
            //                int j = i;
            //                View optimalView = null;
            //              Needs to be rewriten
            //                while (j < mActionContainer.getChildCount()) {
            //                    optimalView = mActionContainer.getChildAt(j);
            //                    if ((action.drawable != null && optimalView instanceof ImageButton) || (action.title !=
            //                            null && optimalView instanceof Button)) {
            //                        mActionContainer.removeViewAt(j);
            //                        mActionContainer.addView(optimalView, i);
            //                        break;
            //                    } else {
            //                        optimalView = null;
            //                        j++;
            //                    }
            //                }
            //                if (optimalView == null) {
            View actionView = null;
            if (action.title != null) {
                Button button = (Button) LayoutInflater.from(context).inflate(R.layout.card_bttn, null);
                textViews.add(button);
                button.setText(action.title);
                button.setOnClickListener(this);
                mActionContainer.addView(button);
                actionView = button;
            } else if (action.drawable != null) {
                ImageButton imageButton = (ImageButton) LayoutInflater.from(context)
                        .inflate(R.layout.card_image_bttn, null);
                imageButton.setImageDrawable(action.drawable);
                imageButton.setOnClickListener(this);
                mActionContainer.addView(imageButton);
                actionView = imageButton;
            }

            //NASTY workaround for the padding
            View space = new View(context);
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                    ViewUtils.convertDPtoPixels(context, 8), ViewUtils.convertDPtoPixels(context, 8));
            mActionContainer.addView(space, params);

            assert actionView != null;
            actionView.setTag(ACTION_ID_TAG, action);
        }
    }

    if (useLightTheme) {
        if (overrideBackground)
            mCardView.setCardBackgroundColor(0xFFFFFF);
        setTextColor(textViews, ContextCompat.getColor(context, android.R.color.primary_text_light),
                ContextCompat.getColor(context, android.R.color.secondary_text_light));

    } else {
        if (overrideBackground)
            mCardView.setCardBackgroundColor(0x424242);
        setTextColor(textViews, ContextCompat.getColor(context, android.R.color.primary_text_dark),
                ContextCompat.getColor(context, android.R.color.secondary_text_dark));
    }

    //Material design guidelines: 2dp resting elevation (or 8dp when raised)
    //Let's assume the card is resting
    //Also: 2dp corner radius
    int dPtoPixels = ViewUtils.convertDPtoPixels(context, 2);
    if (overrideElevation)
        mCardView.setCardElevation(dPtoPixels);
    if (overrideRadius)
        mCardView.setRadius(dPtoPixels);

    return mCardView;
}

From source file:com.initiativaromania.hartabanilorpublici.IRUserInterface.activities.MainActivity.java

private void initTransparentView() {

    /* Avoid displaying infographic if the home button has been pushed */
    Intent intent = getIntent();//from   w  w w .jav a2s  .  co  m
    displayInfographic = intent.getBooleanExtra(EXTRA_DISPLAY_INFOGRAPHIC, true);
    System.out.println("Display info " + displayInfographic);
    if (!displayInfographic) {
        LinearLayout linear = (LinearLayout) findViewById(R.id.transparentLayer);
        linear.setVisibility(View.INVISIBLE);
        return;
    }

    /* Setup the OK button */
    Button okButton = (Button) findViewById(R.id.okButton);
    if (okButton != null) {
        okButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                System.out.println("OK button pushed");

                Animation animation = AnimationUtils.loadAnimation(context, R.anim.slide_down);
                LinearLayout linear = (LinearLayout) findViewById(R.id.transparentLayer);
                linear.startAnimation(animation);
                linear.setVisibility(View.INVISIBLE);

                Toast toast = Toast.makeText(getBaseContext(), "Apasa pe simbolurile  din jurul tau",
                        Toast.LENGTH_LONG);
                toast.setGravity(Gravity.CENTER | Gravity.CENTER_HORIZONTAL, 0, 0);
                toast.show();

                /* Display initial seek bar value */
                Rect thumbRect = seekBar.getThumb().getBounds();
                seekBarValue.setX(thumbRect.exactCenterX());
                DecimalFormat dm = new DecimalFormat("###,###.###");
                seekBarValue.setText(" " + String.valueOf(dm.format(CommManager.aroundTotalSum)) + " EURO ");
                seekBarValue.setVisibility(View.VISIBLE);
                seekBarValue.startAnimation(animationFadeIn);
            }
        });
    }

    /* Send request to get the init data */
    CommManager.requestInitData(new ICommManagerResponse() {
        @Override
        public void processResponse(JSONObject response) {
            MainActivity.this.receiveInitData(response);
        }

        @Override
        public void onErrorOccurred(String errorMsg) {
            Toast.makeText(MainActivity.this, "Eroare conectare la server", Toast.LENGTH_SHORT).show();
        }
    });
}