当前位置: 首页>>代码示例>>Java>>正文


Java LinearLayout.getBackground方法代码示例

本文整理汇总了Java中android.widget.LinearLayout.getBackground方法的典型用法代码示例。如果您正苦于以下问题:Java LinearLayout.getBackground方法的具体用法?Java LinearLayout.getBackground怎么用?Java LinearLayout.getBackground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.LinearLayout的用法示例。


在下文中一共展示了LinearLayout.getBackground方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: disableDays

import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
 * 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));
        }
    }
}
 
开发者ID:jcolladosp,项目名称:ePills,代码行数:24,代码来源:AddPillSetTime.java

示例2: setHassButtonGroup

import android.widget.LinearLayout; //导入方法依赖的package包/类
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);
            }
        }
    }
 
开发者ID:mervinderuiter,项目名称:home-assistant-android,代码行数:62,代码来源:Surface.java


注:本文中的android.widget.LinearLayout.getBackground方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。