List of usage examples for android.view Gravity BOTTOM
int BOTTOM
To view the source code for android.view Gravity BOTTOM.
Click Source Link
From source file:com.example.deii.Fragments.UpdateProfileFragment.java
private void showPicSelectDialog(final Context ctx) { dialog = new Dialog(ctx, R.style.DialogSlideAnim1); dialog.setContentView(R.layout.dialog_select_image); dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent); Window window = dialog.getWindow(); WindowManager.LayoutParams wlp = window.getAttributes(); wlp.gravity = Gravity.BOTTOM; wlp.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND; window.setAttributes(wlp);/* w ww. j av a2 s .c om*/ TextView chooseFromGallery = (TextView) dialog.findViewById(R.id.text_fromGallery); chooseFromGallery.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { loadPermissions(Manifest.permission.READ_EXTERNAL_STORAGE, GALLERY_REQUEST); } else startGallery(); } }); TextView takeFromCamera = (TextView) dialog.findViewById(R.id.text_fromCamera); takeFromCamera.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) loadPermissions(Manifest.permission.CAMERA, CAMERA_REQUEST); else startCamera(); } }); TextView imgCancel = (TextView) dialog.findViewById(R.id.text_dialogClose); imgCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialog.show(); }
From source file:cn.com.caronwer.activity.CertificationActivity.java
@Override public void onClick(View v) { switch (v.getId()) { case R.id.iv_left_white: if (mLl_cer1.getVisibility() == View.GONE) { mLl_cer1.setVisibility(View.VISIBLE); mLl_cer2.setVisibility(View.GONE); } else {//from w w w . j a va2s . co m finish(); } break; case R.id.bv_queren: //? posData(); break; case R.id.pv_sfz: // Toast.makeText(this, "??", Toast.LENGTH_SHORT).show(); imgType = 0; menuWindow = new SelectPicPopupWindow(CertificationActivity.this, itemsOnClick); menuWindow.showAtLocation(findViewById(R.id.activity_rebuild_psd), Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0); break; case R.id.pv_jsz: // Toast.makeText(this, "??", Toast.LENGTH_SHORT).show(); imgType = 1; menuWindow = new SelectPicPopupWindow(CertificationActivity.this, itemsOnClick); menuWindow.showAtLocation(findViewById(R.id.activity_rebuild_psd), Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0); break; case R.id.pv_xsz: // Toast.makeText(this, "??", Toast.LENGTH_SHORT).show(); imgType = 2; menuWindow = new SelectPicPopupWindow(CertificationActivity.this, itemsOnClick); menuWindow.showAtLocation(findViewById(R.id.activity_rebuild_psd), Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0); break; case R.id.pv_cl: // Toast.makeText(this, "?", Toast.LENGTH_SHORT).show(); imgType = 3; menuWindow = new SelectPicPopupWindow(CertificationActivity.this, itemsOnClick); menuWindow.showAtLocation(findViewById(R.id.activity_rebuild_psd), Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0); break; case R.id.bv_next: String name = mEt_name.getText().toString(); String cardid = mEt_cardNo.getText().toString(); String jiasz = mEt_drivingLicense.getText().toString(); String xingsz = mEt_roadPermit.getText().toString(); String cheph = mEt_carNumber.getText().toString(); int chelx = VehType; //String gps = mEt_gps.getText().toString(); if (name.isEmpty() || cardid.isEmpty() || jiasz.isEmpty() || cheph.isEmpty() || xingsz.isEmpty() //|| gps.isEmpty() ) { Toast.makeText(CertificationActivity.this, "??", Toast.LENGTH_SHORT).show(); } else { mJsonObject.addProperty("UserName", name); mJsonObject.addProperty("IDNumber", cardid); mJsonObject.addProperty("UserId", SPtils.getString(this, "UserId", "00000000-0000-0000-0000-000000000000")); mJsonObject.addProperty("DriverId", jiasz); mJsonObject.addProperty("VehicleNo", cheph); mJsonObject.addProperty("TravelCard", xingsz); mJsonObject.addProperty("VehType", chelx); //mJsonObject.addProperty("GpsNo", gps); mLl_cer1.setVisibility(View.GONE); mLl_cer2.setVisibility(View.VISIBLE); } break; } }
From source file:com.edgar.banner.BannerPagerView.java
private void init(AttributeSet attrs, int defStyle) { Context context = getContext(); Resources resource = context.getResources(); LayoutInflater.from(getContext()).inflate(R.layout.banner_layout, this, true); mViewPage = (LoopViewPager) findViewById(R.id.carouse_viewpager); setBannerScroller(new BannerScroller(getContext())); mViewPage.setOverScrollMode(View.OVER_SCROLL_NEVER); mViewPage.setOnPageChangeListener(mCarousePageListener); mBannerPageAdapter = new DefaultBannerPageViewAdapter(); mIndicatorParams.gravity = Gravity.BOTTOM; mPointPadding = resource.getDimensionPixelOffset(R.dimen.point_margin); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BannerPagerView, defStyle, 0); int N = a.getIndexCount(); for (int i = 0; i < N; i++) { int attr = a.getIndex(i); if (attr == R.styleable.BannerPagerView_bannerAnimation) { int transformerType = a.getInt(attr, 0); setBannerPageTransformer(true, TransformerType.convert(transformerType)); } else if (attr == R.styleable.BannerPagerView_enableAutoPlayer) { setEnableAutoPlay(a.getBoolean(attr, false)); } else if (attr == R.styleable.BannerPagerView_indicatorStyle) { mIndicatorStyle = a.getInt(attr, IndicatorStyle.CIRCLE_INDICATOR); } else if (attr == R.styleable.BannerPagerView_indicatorLayout) { int resId = a.getResourceId(attr, 0); if (resId != 0) { View indicatorView = LayoutInflater.from(context).inflate(resId, this, false); if (!(indicatorView instanceof BannerIndicator)) { throw new IllegalArgumentException("Your indicator must implements BannerIndicator."); }/*from w ww .j ava2s .co m*/ mIndicatorView = indicatorView; mBannerIndicator = (BannerIndicator) indicatorView; addView(mIndicatorView); } } else if (attr == R.styleable.BannerPagerView_unSelectDrawable) { mUnSelectedDrawable = a.getDrawable(attr); } else if (attr == R.styleable.BannerPagerView_selectedDrawable) { mSelectedDrawable = a.getDrawable(attr); } else if (attr == R.styleable.BannerPagerView_indicatorGravity) { mIndicatorGravity = a.getInt(attr, Gravity.CENTER); } else if (attr == R.styleable.BannerPagerView_pointPadding) { mPointPadding = a.getDimensionPixelOffset(attr, mPointPadding); } else if (attr == R.styleable.BannerPagerView_indicatorBackground) { mIndicatorBackground = a.getDrawable(attr); } } if (mUnSelectedDrawable == null) { mUnSelectedDrawable = ContextCompat.getDrawable(context, R.drawable.def_circle_normal_background); } if (mSelectedDrawable == null) { mSelectedDrawable = ContextCompat.getDrawable(context, R.drawable.def_circle_selected_background); } if (mIndicatorBackground == null) { mIndicatorBackground = new ColorDrawable(resource.getColor(R.color.indicator_background)); } if (mBannerIndicator == null) { setIndicatorStyle(mIndicatorStyle); } a.recycle(); }
From source file:com.lambdasoup.quickfit.ui.WorkoutListActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Timber.d("onCreate before inflate"); setContentView(R.layout.activity_workout_list); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);//from ww w .java 2 s. c o m //noinspection ConstantConditions toolbar.setTitle(getTitle()); fabAnimationDuration = getResources().getInteger(R.integer.fab_animation_duration); fab = (FloatingActionButton) findViewById(R.id.fab); //noinspection ConstantConditions fab.setOnClickListener(view -> addNewWorkout()); // need to set statelistdrawable referencing vector drawables programmatically, because // support library vector drawable support in 23.3.0 does not allow vector drawable // references in xml statelistdrawables if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { VectorDrawableCompat drawableAdd = VectorDrawableCompat.create(getResources(), R.drawable.ic_add_white_fat_24dp, getTheme()); VectorDrawableCompat drawableExpandLess = VectorDrawableCompat.create(getResources(), R.drawable.ic_expand_less_white_fat_24dp, getTheme()); StateListDrawable stateListDrawable = new StateListDrawable(); stateListDrawable.addState(new int[] { android.R.attr.state_activated }, drawableExpandLess); stateListDrawable.addState(new int[] {}, drawableAdd); fab.setImageDrawable(stateListDrawable); } fabBackgroundToActivated = BackgroundTintListAnimator.create(this, fab, R.color.colorAccent, R.color.colorPrimaryMediumLight, fabAnimationDuration); fabBackgroundToNotActivated = BackgroundTintListAnimator.create(this, fab, R.color.colorPrimaryMediumLight, R.color.colorAccent, fabAnimationDuration); masterDetailView = (MasterDetailLayout) findViewById(R.id.two_panes); if (masterDetailView != null) { // The detail container view will be present only in the // large-screen layouts (res/values-w900dp). // If this view is present, then the // activity should be in two-pane mode. isTwoPane = true; fabAddSchedule = findViewById(R.id.fab_add_schedule); //noinspection ConstantConditions fabAddSchedule.setOnClickListener(view -> addNewSchedule()); fabAddWorkout = findViewById(R.id.fab_add_workout); //noinspection ConstantConditions fabAddWorkout.setOnClickListener(view -> addNewWorkout()); setMiniFabOffsets(); masterDetailView.setAfterCollapse(() -> { CoordinatorLayout.LayoutParams fabLayoutParams = (CoordinatorLayout.LayoutParams) fab .getLayoutParams(); fabLayoutParams.setAnchorId(View.NO_ID); fabLayoutParams.gravity = Gravity.BOTTOM | Gravity.END; fab.setLayoutParams(fabLayoutParams); Fragment schedulesFragment = getSupportFragmentManager().findFragmentById(R.id.schedules_container); getSupportFragmentManager().beginTransaction().remove(schedulesFragment).commit(); }); } workoutsRecyclerView = (EmptyRecyclerView) findViewById(R.id.workout_list); workoutsAdapter = new WorkoutItemRecyclerViewAdapter(this, isTwoPane); workoutsAdapter.setOnWorkoutInteractionListener(this); workoutsRecyclerView.setAdapter(workoutsAdapter); workoutsRecyclerView.addItemDecoration(new DividerItemDecoration(this, false)); readIntentExtras(); if (savedInstanceState != null) { idToSelect = savedInstanceState.getLong(KEY_SHOW_WORKOUT_ID, NO_ID); if (idToSelect == NO_ID) { idToSelect = savedInstanceState.getLong(KEY_SELECTED_ITEM_ID, NO_ID); } } else { idToSelect = FIRST_ITEM_IF_EXISTS; } getLoaderManager().initLoader(0, null, this); Timber.d("onCreate finished"); }
From source file:com.oshi.librcalendarwidget.views.WrapContentHeightViewPager.java
/** * Allows to redraw the view size to wrap the content of the bigger child. * * @param widthMeasureSpec with measured * @param heightMeasureSpec height measured *//*from www.jav a 2s .c om*/ @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); widthMeasuredSpec = widthMeasureSpec; int mode = MeasureSpec.getMode(heightMeasureSpec); if (mode == MeasureSpec.UNSPECIFIED || mode == MeasureSpec.AT_MOST) { if(height == 0) { // measure vertical decor (i.e. PagerTitleStrip) based on ViewPager implementation decorHeight = 0; for (int i = 0; i < getChildCount(); i++) { View child = getChildAt(i); LayoutParams lp = (LayoutParams) child.getLayoutParams(); if(lp != null && lp.isDecor) { int vgrav = lp.gravity & Gravity.VERTICAL_GRAVITY_MASK; boolean consumeVertical = vgrav == Gravity.TOP || vgrav == Gravity.BOTTOM; if(consumeVertical) { decorHeight += child.getMeasuredHeight() ; } } } // make sure that we have an height (not sure if this is necessary because it seems that onPageScrolled is called right after int position = getCurrentItem(); View child = getViewAtPosition(position); if (child != null) { height = measureViewHeight(child); } Log.d(TAG, "onMeasure height:" + height + " decor:" + decorHeight); } int totalHeight = height + decorHeight + getPaddingBottom() + getPaddingTop(); heightMeasureSpec = MeasureSpec.makeMeasureSpec(totalHeight, MeasureSpec.EXACTLY); Log.d(TAG, "onMeasure total height:" + totalHeight); } super.onMeasure(widthMeasureSpec, heightMeasureSpec); }
From source file:mobisocial.musubi.objects.FileObj.java
@Override public View createView(Context context, ViewGroup frame) { LinearLayout container = new LinearLayout(context); container.setLayoutParams(CommonLayouts.FULL_WIDTH); container.setOrientation(LinearLayout.HORIZONTAL); container.setGravity(Gravity.CENTER); ImageView imageView = new ImageView(context); imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); TextView valueTV = new TextView(context); valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); valueTV.setGravity(Gravity.BOTTOM | Gravity.LEFT); valueTV.setPadding(4, 0, 0, 0);//from www . j ava 2s. c o m container.addView(imageView); container.addView(valueTV); return container; }
From source file:com.google.android.apps.santatracker.doodles.tilt.SwimmingFragment.java
@Override protected void firstPassLoadOnUiThread() { final FrameLayout.LayoutParams wrapperLP = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);/*from w ww. ja v a 2 s . c o m*/ final SwimmingFragment that = this; scoreView = getScoreView(); pauseView = getPauseView(); int diveViewBottomMargin = (int) context.getResources().getDimension(R.dimen.dive_margin_bottom); int diveViewStartMargin = (int) context.getResources().getDimension(R.dimen.dive_margin_left); int diveViewSize = (int) context.getResources().getDimension(R.dimen.dive_image_size); FrameLayout.LayoutParams diveViewLP = new LayoutParams(diveViewSize, diveViewSize); diveViewLP.setMargins(diveViewStartMargin, 0, 0, diveViewBottomMargin); diveViewLP.gravity = Gravity.BOTTOM | Gravity.LEFT; if (VERSION.SDK_INT >= 17) { diveViewLP.setMarginStart(diveViewStartMargin); } diveView = new DiveView(context); countdownView = new TextView(context); countdownView.setGravity(Gravity.CENTER); countdownView.setTextColor(context.getResources().getColor(R.color.ui_text_yellow)); countdownView.setTypeface(Typeface.DEFAULT_BOLD); countdownView.setText("0"); countdownView.setVisibility(View.INVISIBLE); Locale locale = context.getResources().getConfiguration().locale; countdownView.setText(NumberFormat.getInstance(locale).format(3)); Point screenDimens = AndroidUtils.getScreenSize(); UIUtil.fitToBounds(countdownView, screenDimens.x / 10, screenDimens.y / 10); LinearLayout gameView = new LinearLayout(context); gameView.setOrientation(LinearLayout.VERTICAL); // Add game view. swimmingView = new SwimmingView(context); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 7); gameView.addView(swimmingView, lp); if (editorMode) { LinearLayout buttonWrapper = new LinearLayout(context); buttonWrapper.setOrientation(LinearLayout.HORIZONTAL); lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1); gameView.addView(buttonWrapper, lp); resetButton = getButton(R.string.reset_level, new OnClickListener() { @Override public void onClick(View v) { SwimmingModel level = levelManager.loadDefaultLevel(); initializeLevel(level, false); getActivity().getSharedPreferences(context.getString(R.string.swimming), Context.MODE_PRIVATE) .edit().putString(CURRENT_LEVEL_KEY, null).commit(); } }); deleteButton = getButton(R.string.delete_levels, new OnClickListener() { @Override public void onClick(View v) { DialogFragment dialogFragment = new DeleteLevelDialogFragment(); dialogFragment.show(getActivity().getFragmentManager(), "delete"); } }); loadButton = getButton(R.string.load_level, new OnClickListener() { @Override public void onClick(View v) { DialogFragment dialogFragment = new LoadLevelDialogFragment(that); dialogFragment.show(getActivity().getFragmentManager(), "load"); } }); saveButton = getButton(R.string.save_level, new OnClickListener() { @Override public void onClick(View v) { DialogFragment dialogFragment = new SaveLevelDialogFragment(that); dialogFragment.show(getActivity().getFragmentManager(), "save"); } }); collisionModeButton = new ToggleButton(context); collisionModeButton.setText(R.string.scenery_mode); collisionModeButton.setTextOff(context.getString(R.string.scenery_mode)); collisionModeButton.setTextOn(context.getString(R.string.collision_mode)); collisionModeButton.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { model.collisionMode = isChecked; } }); lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT, 1); buttonWrapper.addView(deleteButton, lp); buttonWrapper.addView(resetButton, lp); buttonWrapper.addView(loadButton, lp); buttonWrapper.addView(saveButton, lp); buttonWrapper.addView(collisionModeButton, lp); } sensorManager = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE); accelerometerSensor = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); if (accelerometerSensor == null) { // TODO: The game won't be playable without this, so what should we do? Log.d(TAG, "Accelerometer sensor is null"); } displayRotation = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay() .getRotation(); wrapper.addView(gameView, 0, wrapperLP); wrapper.addView(countdownView, 1); wrapper.addView(diveView, 2, diveViewLP); wrapper.addView(scoreView, 3); wrapper.addView(pauseView, 4); }
From source file:android.support.designox.widget.CollapsingToolbarLayout.java
public CollapsingToolbarLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); ThemeUtils.checkAppCompatTheme(context); mCollapsingTextHelper = new CollapsingTextHelper(this); mCollapsingTextHelper.setTextSizeInterpolator(AnimationUtils.DECELERATE_INTERPOLATOR); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CollapsingToolbarLayout, defStyleAttr, R.style.Widget_Design_CollapsingToolbar); mCollapsingTextHelper.setExpandedTextGravity(a.getInt( R.styleable.CollapsingToolbarLayout_expandedTitleGravity, GravityCompat.START | Gravity.BOTTOM)); mCollapsingTextHelper/*from w w w .ja va2s. c o m*/ .setCollapsedTextGravity(a.getInt(R.styleable.CollapsingToolbarLayout_collapsedTitleGravity, GravityCompat.START | Gravity.CENTER_VERTICAL)); mExpandedMarginStart = mExpandedMarginTop = mExpandedMarginEnd = mExpandedMarginBottom = a .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMargin, 0); if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginStart)) { mExpandedMarginStart = a .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginStart, 0); } if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginEnd)) { mExpandedMarginEnd = a.getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginEnd, 0); } if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginTop)) { mExpandedMarginTop = a.getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginTop, 0); } if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginBottom)) { mExpandedMarginBottom = a .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginBottom, 0); } mCollapsingTitleEnabled = a.getBoolean(R.styleable.CollapsingToolbarLayout_titleEnabled, true); setTitle(a.getText(R.styleable.CollapsingToolbarLayout_title)); // First load the default text appearances mCollapsingTextHelper.setExpandedTextAppearance(R.style.TextAppearance_Design_CollapsingToolbar_Expanded); mCollapsingTextHelper.setCollapsedTextAppearance(R.style.TextAppearance_AppCompat_Widget_ActionBar_Title); // Now overlay any custom text appearances if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleTextAppearance)) { mCollapsingTextHelper.setExpandedTextAppearance( a.getResourceId(R.styleable.CollapsingToolbarLayout_expandedTitleTextAppearance, 0)); } if (a.hasValue(R.styleable.CollapsingToolbarLayout_collapsedTitleTextAppearance)) { mCollapsingTextHelper.setCollapsedTextAppearance( a.getResourceId(R.styleable.CollapsingToolbarLayout_collapsedTitleTextAppearance, 0)); } setContentScrim(a.getDrawable(R.styleable.CollapsingToolbarLayout_contentScrim)); setStatusBarScrim(a.getDrawable(R.styleable.CollapsingToolbarLayout_statusBarScrim)); mToolbarId = a.getResourceId(R.styleable.CollapsingToolbarLayout_toolbarId, -1); a.recycle(); setWillNotDraw(false); ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4ox.view.OnApplyWindowInsetsListener() { @Override public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) { return setWindowInsets(insets); } }); }
From source file:com.muzakki.ahmad.widget.CollapsingToolbarLayout.java
public CollapsingToolbarLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); ThemeUtils.checkAppCompatTheme(context); mCollapsingTextHelper = new CollapsingTextHelper(this); mCollapsingTextHelper.setTextSizeInterpolator(AnimationUtils.DECELERATE_INTERPOLATOR); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CollapsingToolbarLayout, defStyleAttr, R.style.Widget_Design_CollapsingToolbar); mCollapsingTextHelper.setExpandedTextGravity(a.getInt( R.styleable.CollapsingToolbarLayout_expandedTitleGravity, GravityCompat.START | Gravity.BOTTOM)); mCollapsingTextHelper/*from w ww. ja v a 2 s .co m*/ .setCollapsedTextGravity(a.getInt(R.styleable.CollapsingToolbarLayout_collapsedTitleGravity, GravityCompat.START | Gravity.CENTER_VERTICAL)); mExpandedMarginStart = mExpandedMarginTop = mExpandedMarginEnd = mExpandedMarginBottom = a .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMargin, 0); if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginStart)) { mExpandedMarginStart = a .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginStart, 0); } if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginEnd)) { mExpandedMarginEnd = a.getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginEnd, 0); } if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginTop)) { mExpandedMarginTop = a.getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginTop, 0); } if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginBottom)) { mExpandedMarginBottom = a .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginBottom, 0); } mCollapsingTitleEnabled = a.getBoolean(R.styleable.CollapsingToolbarLayout_titleEnabled, true); setTitle(a.getText(R.styleable.CollapsingToolbarLayout_title)); // begin modification TypedArray mStyle = context.obtainStyledAttributes(attrs, R.styleable.SubtitleCollapsingToolbar, defStyleAttr, R.style.SubtitleCollapsingToolbar); if (mStyle.hasValue(R.styleable.SubtitleCollapsingToolbar_subtitle)) setSubtitle(mStyle.getText(R.styleable.SubtitleCollapsingToolbar_subtitle).toString()); //load default appearances first mCollapsingTextHelper.setCollapsedSubAppearance(R.style.CollapsedSubtitleAppearance); mCollapsingTextHelper.setExpandedSubAppearance(R.style.ExpandedSubtitleAppearance); // now apply custom sub appearance if (mStyle.hasValue(R.styleable.SubtitleCollapsingToolbar_collapsedSubtitleAppearance)) { mCollapsingTextHelper.setCollapsedSubAppearance( mStyle.getResourceId(R.styleable.SubtitleCollapsingToolbar_collapsedSubtitleAppearance, 0)); } if (mStyle.hasValue(R.styleable.SubtitleCollapsingToolbar_expandedSubtitleAppearance)) { mCollapsingTextHelper.setExpandedSubAppearance( mStyle.getResourceId(R.styleable.SubtitleCollapsingToolbar_expandedSubtitleAppearance, 0)); } // end // First load the default text appearances mCollapsingTextHelper.setExpandedTextAppearance(R.style.TextAppearance_Design_CollapsingToolbar_Expanded); mCollapsingTextHelper.setCollapsedTextAppearance( android.support.v7.appcompat.R.style.TextAppearance_AppCompat_Widget_ActionBar_Title); // Now overlay any custom text appearances if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleTextAppearance)) { mCollapsingTextHelper.setExpandedTextAppearance( a.getResourceId(R.styleable.CollapsingToolbarLayout_expandedTitleTextAppearance, 0)); } if (a.hasValue(R.styleable.CollapsingToolbarLayout_collapsedTitleTextAppearance)) { mCollapsingTextHelper.setCollapsedTextAppearance( a.getResourceId(R.styleable.CollapsingToolbarLayout_collapsedTitleTextAppearance, 0)); } mScrimVisibleHeightTrigger = a .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_scrimVisibleHeightTrigger, -1); mScrimAnimationDuration = a.getInt(R.styleable.CollapsingToolbarLayout_scrimAnimationDuration, DEFAULT_SCRIM_ANIMATION_DURATION); setContentScrim(a.getDrawable(R.styleable.CollapsingToolbarLayout_contentScrim)); setStatusBarScrim(a.getDrawable(R.styleable.CollapsingToolbarLayout_statusBarScrim)); mToolbarId = a.getResourceId(R.styleable.CollapsingToolbarLayout_toolbarId, -1); a.recycle(); setWillNotDraw(false); ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() { @Override public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) { return onWindowInsetChanged(insets); } }); }
From source file:co.ceryle.radiorealbutton.library.RadioRealButtonGroup.java
private void setSelectorAttrs() { FrameLayout.LayoutParams selectorParams = (FrameLayout.LayoutParams) selectorContainer.getLayoutParams(); FrameLayout.LayoutParams bottomLineParams = (FrameLayout.LayoutParams) v_bottomLine.getLayoutParams(); if (selectorBringToFront) selectorContainer.bringToFront(); if (!selectorFullSize) selectorParams.height = selectorSize; int topMargin = 0, bottomMargin = 0; if (selectorTop) { selectorParams.gravity = Gravity.TOP; bottomLineParams.gravity = Gravity.TOP; topMargin = bottomLineSize;//w w w. j a v a 2 s. co m } else if (selectorBottom) { selectorParams.gravity = Gravity.BOTTOM; bottomLineParams.gravity = Gravity.BOTTOM; bottomMargin = bottomLineSize; } if (selectorAboveOfBottomLine) { selectorParams.setMargins(0, topMargin, 0, bottomMargin); } }