private View getSeparatorView() { View separator = new View(activity); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1); int m8 = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); int m5 = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 5, getResources().getDisplayMetrics()); params.setMargins(m8, m5, m8, m5); separator.setLayoutParams(params); TypedValue typedValue = new TypedValue(); activity.getTheme().resolveAttribute(R.attr.separator_color, typedValue, true); separator.setBackgroundColor(typedValue.data); return separator; }
private void setupSwiper() { SwipeLayout swipeLayout = buildSwipeLayout(); if (swipeLayout == null) return; TypedArray a = mActivity.getTheme().obtainStyledAttributes(new int[]{ android.R.attr.windowBackground }); int background = a.getResourceId(0, 0); a.recycle(); // replace content view ViewGroup decor = (ViewGroup) mActivity.getWindow().getDecorView(); decor.setBackgroundColor(ContextCompat.getColor(mContext, android.R.color.transparent)); ViewGroup decorChild = (ViewGroup) decor.getChildAt(0); if (SwipeLayout.class.isInstance(decorChild)) { return; } decorChild.setBackgroundResource(background); decor.removeView(decorChild); swipeLayout.addView(decorChild); decor.addView(swipeLayout); } }
private int getResourceIdFromAttr(@AttrRes int attr) { final TypedValue typedValue = new TypedValue(); activity.getTheme().resolveAttribute(attr, typedValue, true); return typedValue.resourceId; }
@Override public Resources.Theme getTheme() { if (hostActivityHelper!=null && hostActivityHelper.isInit()) { return hostActivityHelper.getTheme(); } return super.getTheme(); }
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { // !!! Make some modifications Toast.makeText(getApplicationContext(), "Hello World!", Toast.LENGTH_SHORT).show(); final AppCompatDelegate delegate = getDelegate(); delegate.installViewFactory(); delegate.onCreate(savedInstanceState); if (delegate.applyDayNight() && mThemeId != 0) { // If DayNight has been applied, we need to re-apply the theme for // the changes to take effect. On API 23+, we should bypass // setTheme(), which will no-op if the theme ID is identical to the // current theme ID. if (Build.VERSION.SDK_INT >= 23) { onApplyThemeResource(getTheme(), mThemeId, false); } else { setTheme(mThemeId); } } super.onCreate(savedInstanceState); }