本文整理汇总了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));
}
}
}
示例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);
}
}
}