Search in sources :

Example 21 with LayoutParams

use of android.widget.RelativeLayout.LayoutParams in project KJFrameForAndroid by kymjs.

the class Splash method screenAdaptation.

/**
 * 屏幕适配
 */
private void screenAdaptation() {
    RelativeLayout.LayoutParams boxParams = (LayoutParams) mRlBox.getLayoutParams();
    boxParams.width = (int) (AppContext.screenW * 0.8);
    boxParams.height = (int) (AppContext.screenH * 0.6);
    mRlBox.setLayoutParams(boxParams);
    RelativeLayout.LayoutParams goParams = (LayoutParams) mBtnGo.getLayoutParams();
    goParams.width = (int) (AppContext.screenW * 0.7);
    goParams.height = (int) getResources().getDimension(R.dimen.splash_btn_go_height);
    mBtnGo.setLayoutParams(goParams);
    RelativeLayout.LayoutParams headParams = (RelativeLayout.LayoutParams) mImgHead.getLayoutParams();
    headParams.topMargin = (int) ((AppContext.screenH * 0.16) / 2);
    mImgHead.setLayoutParams(headParams);
}
Also used : LayoutParams(android.widget.RelativeLayout.LayoutParams) RelativeLayout(android.widget.RelativeLayout) LayoutParams(android.widget.RelativeLayout.LayoutParams)

Example 22 with LayoutParams

use of android.widget.RelativeLayout.LayoutParams in project Etar-Calendar by Etar-Group.

the class AllInOneActivity method onCreate.

@Override
protected void onCreate(Bundle icicle) {
    setTheme(R.style.CalendarTheme_WithActionBarWallpaper);
    super.onCreate(icicle);
    dynamicTheme.onCreate(this);
    // This needs to be created before setContentView
    mController = CalendarController.getInstance(this);
    // Create notification channel
    AlertService.createChannels(this);
    // Check and ask for most needed permissions
    checkAppPermissions();
    // Get time from intent or icicle
    long timeMillis = -1;
    int viewType = -1;
    final Intent intent = getIntent();
    if (icicle != null) {
        timeMillis = icicle.getLong(BUNDLE_KEY_RESTORE_TIME);
        viewType = icicle.getInt(BUNDLE_KEY_RESTORE_VIEW, -1);
    } else {
        String action = intent.getAction();
        if (Intent.ACTION_VIEW.equals(action)) {
            // Open EventInfo later
            timeMillis = parseViewAction(intent);
        }
        if (timeMillis == -1) {
            timeMillis = Utils.timeFromIntentInMillis(intent);
        }
    }
    if (viewType == -1 || viewType > ViewType.MAX_VALUE) {
        viewType = Utils.getViewTypeFromIntentAndSharedPref(this);
    }
    mTimeZone = Utils.getTimeZone(this, mHomeTimeUpdater);
    Time t = new Time(mTimeZone);
    t.set(timeMillis);
    if (DEBUG) {
        if (icicle != null && intent != null) {
            Log.d(TAG, "both, icicle:" + icicle.toString() + "  intent:" + intent.toString());
        } else {
            Log.d(TAG, "not both, icicle:" + icicle + " intent:" + intent);
        }
    }
    Resources res = getResources();
    mHideString = res.getString(R.string.hide_controls);
    mShowString = res.getString(R.string.show_controls);
    mOrientation = res.getConfiguration().orientation;
    if (mOrientation == Configuration.ORIENTATION_LANDSCAPE) {
        mControlsAnimateWidth = (int) res.getDimension(R.dimen.calendar_controls_width);
        if (mControlsParams == null) {
            mControlsParams = new LayoutParams(mControlsAnimateWidth, 0);
        }
        mControlsParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    } else {
        // Make sure width is in between allowed min and max width values
        mControlsAnimateWidth = Math.max(res.getDisplayMetrics().widthPixels * 45 / 100, (int) res.getDimension(R.dimen.min_portrait_calendar_controls_width));
        mControlsAnimateWidth = Math.min(mControlsAnimateWidth, (int) res.getDimension(R.dimen.max_portrait_calendar_controls_width));
    }
    mControlsAnimateHeight = (int) res.getDimension(R.dimen.calendar_controls_height);
    mHideControls = !Utils.getSharedPreference(this, GeneralPreferences.KEY_SHOW_CONTROLS, true);
    mIsMultipane = Utils.getConfigBool(this, R.bool.multiple_pane_config);
    mIsTabletConfig = Utils.getConfigBool(this, R.bool.tablet_config);
    mShowAgendaWithMonth = Utils.getConfigBool(this, R.bool.show_agenda_with_month);
    mShowCalendarControls = Utils.getConfigBool(this, R.bool.show_calendar_controls);
    mShowEventDetailsWithAgenda = Utils.getConfigBool(this, R.bool.show_event_details_with_agenda);
    mShowEventInfoFullScreenAgenda = Utils.getConfigBool(this, R.bool.agenda_show_event_info_full_screen);
    mShowEventInfoFullScreen = Utils.getConfigBool(this, R.bool.show_event_info_full_screen);
    mCalendarControlsAnimationTime = res.getInteger(R.integer.calendar_controls_animation_time);
    Utils.setAllowWeekForDetailView(mIsMultipane);
    // setContentView must be called before configureActionBar
    binding = AllInOneMaterialBinding.inflate(getLayoutInflater());
    setContentView(binding.getRoot());
    mDrawerLayout = binding.drawerLayout;
    mNavigationView = binding.navigationView;
    mFab = binding.floatingActionButton;
    if (mIsTabletConfig) {
        mDateRange = binding.include.dateBar;
        mWeekTextView = binding.include.weekNum;
    } else {
        mDateRange = DateRangeTitleBinding.inflate(getLayoutInflater()).getRoot();
    }
    setupToolbar(viewType);
    setupNavDrawer();
    setupFloatingActionButton();
    mHomeTime = binding.include.homeTime;
    mMiniMonth = binding.include.miniMonth;
    if (mIsTabletConfig && mOrientation == Configuration.ORIENTATION_PORTRAIT) {
        mMiniMonth.setLayoutParams(new RelativeLayout.LayoutParams(mControlsAnimateWidth, mControlsAnimateHeight));
    }
    mCalendarsList = binding.include.calendarList;
    mMiniMonthContainer = binding.include.miniMonthContainer;
    mSecondaryPane = binding.include.secondaryPane;
    // Must register as the first activity because this activity can modify
    // the list of event handlers in it's handle method. This affects who
    // the rest of the handlers the controller dispatches to are.
    mController.registerFirstEventHandler(HANDLER_KEY, this);
    initFragments(timeMillis, viewType, icicle);
    // Listen for changes that would require this to be refreshed
    SharedPreferences prefs = GeneralPreferences.Companion.getSharedPreferences(this);
    prefs.registerOnSharedPreferenceChangeListener(this);
    mContentResolver = getContentResolver();
}
Also used : LayoutParams(android.widget.RelativeLayout.LayoutParams) SharedPreferences(android.content.SharedPreferences) RelativeLayout(android.widget.RelativeLayout) Intent(android.content.Intent) Time(android.text.format.Time) Resources(android.content.res.Resources) LayoutParams(android.widget.RelativeLayout.LayoutParams)

Aggregations

LayoutParams (android.widget.RelativeLayout.LayoutParams)22 RelativeLayout (android.widget.RelativeLayout)8 View (android.view.View)7 ChangeBounds (android.transition.ChangeBounds)4 ViewGroup (android.view.ViewGroup)4 Button (android.widget.Button)4 AbsListView (android.widget.AbsListView)3 ListAdapter (android.widget.ListAdapter)3 ListView (android.widget.ListView)3 TextView (android.widget.TextView)3 Point (android.graphics.Point)2 SpannableString (android.text.SpannableString)2 LayoutInflater (android.view.LayoutInflater)2 Animation (android.view.animation.Animation)2 AnimationListener (android.view.animation.Animation.AnimationListener)2 Transformation (android.view.animation.Transformation)2 InputMethodManager (android.view.inputmethod.InputMethodManager)2 GridView (android.widget.GridView)2 SuppressLint (android.annotation.SuppressLint)1 Intent (android.content.Intent)1