本文整理匯總了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);
}
}
}