Java Code Examples for android.widget.LinearLayout.getBackground()

The following are Jave code examples for showing how to use getBackground() of the android.widget.LinearLayout class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: ePills   File: AddPillSetTime.java   View Source Code Vote up 6 votes
/**
 * This view disables tapping on the day objects and on the endDate label. It also
 * colors them following the material design specification.
  */
private void disableDays() {
    double opacity = 0.26; //Following the material specification, disabled buttons have opacity 26%
    for (int i = 0; i < weekdaysSelection.length; i++) {
        LinearLayout day = getDayLayout(i);
        day.setOnClickListener(null);
        endDateTextView.setOnClickListener(null);
        endDateTextView.setAlpha( (float) (opacity * 255 /100));
        int colorBlack = ContextCompat.getColor(getBaseContext(), R.color.black);
        if (day.getBackground()== null) {
            Drawable bg = ContextCompat.getDrawable(getBaseContext(), R.drawable.circle_step);
            bg.setColorFilter(new PorterDuffColorFilter(colorBlack, PorterDuff.Mode.SRC_IN));
            bg.setAlpha((int) (opacity * 255));
            day.setBackground(bg);
        } else {
            day.getBackground().setColorFilter(new PorterDuffColorFilter(colorBlack, PorterDuff.Mode.SRC_IN));
            day.getBackground().setAlpha((int) (opacity * 255));
        }
    }
}
 
Example 2
Project: home-assistant-android   File: Surface.java   View Source Code Vote up 5 votes
private void setHassButtonGroup(HassGroupEntity groupEntity, View shortcutButton) {

        final View groupContainer = getLayoutInflater().inflate(R.layout.group_list_vertical_scrollable, null);
        scrollViewItems.addView(groupContainer);
        LinearLayout groupsView = (LinearLayout)groupContainer.findViewById(R.id.groupsView);

        View childContainer = getLayoutInflater().inflate(R.layout.childentity_list_vertical_scrollable, null);
        scrollViewItems.addView(childContainer);
        childContainer.setVisibility(GONE);

        View lightControl = getLayoutInflater().inflate(R.layout.lightcontrol, null);
        scrollViewItems.addView(lightControl);
        lightControl.setVisibility(GONE);

        shortcutButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                scrollView.smoothScrollTo(groupContainer.getLeft(), 0);
            }
        });

        for (HassEntity entity : groupEntity.getEntities()) {

            View child = getLayoutInflater().inflate(R.layout.lightcontrol_list_item_medium, null);
            LinearLayout buttonLayout = (LinearLayout)child.findViewById(R.id.buttonLayout);
            Drawable background = buttonLayout.getBackground();
            background.setTint(entity.getColor());


            TextView childText = (TextView)child.findViewById(R.id.buttonText);
            childText.setText(entity.getName());

            try {
                String icon = entity.getIcon();

                Drawable drawable = thisActivity.getDrawable(getHassIconResource(icon));
                drawable.setTint(getResources().getColor(R.color.white));

                ImageView childImage = (ImageView)child.findViewById(R.id.buttonImage);
                childImage.setBackground(drawable);


            } catch (Exception e) {
                Log.e("LightControl", e.getMessage());
            }

            groupsView.addView(child);

            if (entity instanceof LightControlInterface) {
                setLightControlButton((LightControlInterface)entity, child, childContainer, lightControl);
            }

            if (entity instanceof SceneInterface) {
                setSceneButton((SceneInterface) entity, child);
            }

            if (entity instanceof SensorInterface) {
                setSensor((SensorInterface) entity, child);
            }
        }
    }