Example usage for android.view ViewGroup setBackgroundResource

List of usage examples for android.view ViewGroup setBackgroundResource

Introduction

In this page you can find the example usage for android.view ViewGroup setBackgroundResource.

Prototype

@RemotableViewMethod
public void setBackgroundResource(@DrawableRes int resid) 

Source Link

Document

Set the background to a given resource.

Usage

From source file:sse.tf141.suncore.MainActivity.java

public static void setTabMargin(ViewGroup Mlayout, Fragment fragment) {
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
            fragment.getResources().getDisplayMetrics());
    params.setMargins(margin, margin, margin, margin);
    Mlayout.setLayoutParams(params);/*w  w w.  j a  va2 s.  c om*/
    Mlayout.setLayoutParams(params);
    Mlayout.setBackgroundResource(R.drawable.background_card);
}

From source file:de.egore911.drilog.adapter.ShowDataAdapter.java

private void setDefaultCellBackground(int position, ViewGroup row, boolean selected) {
    if (getCount() == 0) {
        // Only one element -> border at top and bottom
        int drawable = R.drawable.table_shape_both;
        row.setBackgroundResource(drawable);
    } else if (getItemViewType(position) == TYPE_NAME) {
        // User -> border at top
        int drawable = R.drawable.table_shape_top;
        row.setBackgroundResource(drawable);
    } else if (position == (getCount() - 1) || (getItem(position + 1) instanceof User)) {
        // Last element or next element is a user -> border at bottom
        int drawable = R.drawable.table_shape_bottom;
        row.setBackgroundResource(drawable);
    } else {/*from w w  w.  j  a v  a2 s.c o  m*/
        // Nothing special, border at the left and right
        int drawable = R.drawable.table_shape_middle;
        row.setBackgroundResource(drawable);
    }
}

From source file:com.rubika.aotalk.aou.FragmentCalendar.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    container.setBackgroundResource(0);
    return super.onCreateView(inflater, container, savedInstanceState);
}

From source file:app.newbee.lib.swipeback.SwipeBackLayout.java

public void attachToActivity(Activity activity) {
    mActivity = activity;/*from  w ww. java  2  s. co m*/
    TypedArray a = activity.getTheme().obtainStyledAttributes(new int[] { android.R.attr.windowBackground });
    int background = a.getResourceId(0, 0);
    a.recycle();

    ViewGroup decor = (ViewGroup) activity.getWindow().getDecorView().findViewById(Window.ID_ANDROID_CONTENT);
    ViewGroup decorChild = (ViewGroup) decor.getChildAt(0);
    decorChild.setBackgroundResource(background);
    decor.removeView(decorChild);
    addView(decorChild);
    setContentView(decorChild);
    decor.addView(this);
}

From source file:com.android.fastlibrary.ui.activity.swipeback.SwipeBackLayout.java

public void attachToActivity(Activity activity) {
    mActivity = activity;/*from   ww  w.ja v  a2  s.c  om*/
    TypedArray a = activity.getTheme().obtainStyledAttributes(new int[] { android.R.attr.windowBackground });
    int background = a.getResourceId(0, 0);
    a.recycle();

    ViewGroup decor = (ViewGroup) activity.getWindow().getDecorView();
    ViewGroup decorChild = (ViewGroup) decor.getChildAt(0);
    decorChild.setBackgroundResource(background);
    decor.removeView(decorChild);
    addView(decorChild);
    setContentView(decorChild);
    decor.addView(this);
}

From source file:com.bowyoung.enhancelibrary.libs.swipeback.SwipeBackLayout.java

public void attachToActivity(BaseEnhanceActivity activity) {
    mActivity = activity;//from ww  w  .ja  v a 2 s  .c o  m
    TypedArray a = activity.getTheme().obtainStyledAttributes(new int[] { android.R.attr.windowBackground });
    int background = a.getResourceId(0, 0);
    a.recycle();

    ViewGroup decor = (ViewGroup) activity.getWindow().getDecorView();
    ViewGroup decorChild = (ViewGroup) decor.getChildAt(0);
    decorChild.setBackgroundResource(background);
    decor.removeView(decorChild);
    addView(decorChild);
    setContentView(decorChild);
    decor.addView(this);
}

From source file:com.marcohc.robotocalendar.RobotoCalendarView.java

public void markDayAsSelectedDay(Date currentDate) {

    // Initialize attributes
    Calendar currentCalendar = getCurrentCalendar();
    currentCalendar.setTime(currentDate);

    // Clear previous marks
    clearDayOfTheMonthStyle(lastSelectedDay);

    markDayAsCurrentDay(lastCurrentDay);

    // Store current values as last values
    storeLastValues(currentDate);/*from  w  w  w.j a  v  a 2 s.c  o m*/

    // Mark current day as selected
    ViewGroup dayOfMonthBackground = getDayOfMonthBackground(currentCalendar);
    dayOfMonthBackground.setBackgroundResource(R.drawable.circle);
}

From source file:com.marcohc.robotocalendar.RobotoCalendarView.java

public void selectEndDay(Date currentDate) {
    // Initialize attributes
    Calendar currentCalendar = getCurrentCalendar();
    currentCalendar.setTime(currentDate);
    currentCalendar.set(Calendar.HOUR_OF_DAY, 0);
    currentCalendar.set(Calendar.MINUTE, 0); // set minute in hour
    currentCalendar.set(Calendar.SECOND, 0); // set second in minute
    currentCalendar.set(Calendar.MILLISECOND, 0);
    // Clear previous marks
    clearDayOfTheMonthStyle(endDay);//from  w  w  w  . j a  v  a  2 s.  c o  m
    endDay = currentCalendar.getTime();
    markDayAsCurrentDay(lastCurrentDay);

    // Store current values as last values
    storeLastValues(currentDate);
    // Mark current day as selected
    ViewGroup dayOfMonthBackground = getDayOfMonthBackground(currentCalendar);
    dayOfMonthBackground.setBackgroundResource(R.drawable.circle);
    updateBackgroundSelectDays();
}

From source file:com.marcohc.robotocalendar.RobotoCalendarView.java

public void selectStartDay(Date currentDate) {
    // Initialize attributes
    Calendar currentCalendar = getCurrentCalendar();
    currentCalendar.setTime(currentDate);
    currentCalendar.set(Calendar.HOUR_OF_DAY, 0);
    currentCalendar.set(Calendar.MINUTE, 0); // set minute in hour
    currentCalendar.set(Calendar.SECOND, 0); // set second in minute
    currentCalendar.set(Calendar.MILLISECOND, 0);
    // Clear previous marks
    clearDayOfTheMonthStyle(startDay);/*from   ww w  .ja  v  a 2  s.  co m*/
    startDay = currentCalendar.getTime();
    markDayAsCurrentDay(lastCurrentDay);

    // Store current values as last values
    storeLastValues(currentDate);

    // Mark current day as selected
    ViewGroup dayOfMonthBackground = getDayOfMonthBackground(currentCalendar);
    dayOfMonthBackground.setBackgroundResource(R.drawable.circle);
    TextView dayOfMonth = getDayOfMonthText(currentCalendar);
    dayOfMonth.setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_select_day));

}

From source file:com.marcohc.robotocalendar.RobotoCalendarView.java

private void clearDayOfTheMonthStyle(Date currentDate) {

    if (currentDate != null) {
        Calendar calendar = getCurrentCalendar();
        calendar.setTime(currentDate);//from w  w w.jav  a 2  s .  c  om
        ViewGroup dayOfMonthBackground = getDayOfMonthBackground(calendar);
        ViewGroup dayOfMonthBackgroundContainerund = getDayOfMonthBackgroundContainer(calendar);
        dayOfMonthBackground.setBackgroundResource(android.R.color.transparent);
        dayOfMonthBackgroundContainerund.setBackgroundResource(0);
        TextView dayOfMonth = getDayOfMonthText(calendar);
        dayOfMonth.setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_day_of_month));
    }
}