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.kccomy.orgar.ui.note.NoteFragment.java
private void initPopupWindow() { View popupWindowView = getActivity().getLayoutInflater().inflate(R.layout.popup_window_share, null); //??/*from w w w . j a va 2s.c o m*/ Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.addCategory(Intent.CATEGORY_DEFAULT); shareIntent.setType("text/plain"); PackageManager packageManager = getContext().getPackageManager(); List<ResolveInfo> resolveInfos = packageManager.queryIntentActivities(shareIntent, PackageManager.GET_RESOLVED_FILTER); // RecyclerAdapter RecyclerView recyclerView = (RecyclerView) popupWindowView.findViewById(R.id.popup_widow_share_recycler); ShareAdapter shareAdapter = new ShareAdapter(packageManager); shareAdapter.setData(resolveInfos); shareAdapter.setAppIconClickListener(shareListener); recyclerView.setAdapter(shareAdapter); recyclerView .setLayoutManager(new GridLayoutManager(getContext(), 2, LinearLayoutManager.HORIZONTAL, false)); // ?PopupWindow popupWindowView.setFocusable(true); popupWindowView.setFocusableInTouchMode(true); PopupWindow popupWindow = new PopupWindow(popupWindowView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); popupWindow.setFocusable(true); popupWindow.setOutsideTouchable(true); popupWindow.setBackgroundDrawable(new ColorDrawable(0x00000000)); popupWindow.setAnimationStyle(R.style.anim_menu_bottombar); setWindowAlpha(0.5f); popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { setWindowAlpha(1f); } }); popupWindow.showAtLocation(getActivity().getLayoutInflater().inflate(R.layout.fragment_note, null), Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0); }
From source file:com.quran.labs.androidquran.widgets.SlidingUpPanelLayout.java
public SlidingUpPanelLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) { mShadowDrawable = null;/*ww w .jav a 2s. c o m*/ mScrollTouchSlop = 0; mDragHelper = null; return; } if (attrs != null) { TypedArray defAttrs = context.obtainStyledAttributes(attrs, DEFAULT_ATTRS); if (defAttrs != null) { int gravity = defAttrs.getInt(0, Gravity.NO_GRAVITY); if (gravity != Gravity.TOP && gravity != Gravity.BOTTOM) { throw new IllegalArgumentException("gravity must be set to either top or bottom"); } mIsSlidingUp = gravity == Gravity.BOTTOM; } defAttrs.recycle(); TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlidingUpPanelLayout); if (ta != null) { mPanelHeight = ta.getDimensionPixelSize(R.styleable.SlidingUpPanelLayout_panelHeight, -1); mShadowHeight = ta.getDimensionPixelSize(R.styleable.SlidingUpPanelLayout_shadowHeight, -1); mParallaxOffset = ta.getDimensionPixelSize(R.styleable.SlidingUpPanelLayout_parallaxOffset, -1); mMinFlingVelocity = ta.getInt(R.styleable.SlidingUpPanelLayout_flingVelocity, DEFAULT_MIN_FLING_VELOCITY); mCoveredFadeColor = ta.getColor(R.styleable.SlidingUpPanelLayout_fadeColor, DEFAULT_FADE_COLOR); mDragViewResId = ta.getResourceId(R.styleable.SlidingUpPanelLayout_dragView, -1); mOverlayContent = ta.getBoolean(R.styleable.SlidingUpPanelLayout_overlay, DEFAULT_OVERLAY_FLAG); mArbitraryPositionEnabled = ta.getBoolean(R.styleable.SlidingUpPanelLayout_arbitraryPosition, DEFAULT_ARBITRARY_POS_FLAG); } ta.recycle(); } final float density = context.getResources().getDisplayMetrics().density; if (mPanelHeight == -1) { mPanelHeight = (int) (DEFAULT_PANEL_HEIGHT * density + 0.5f); } if (mShadowHeight == -1) { mShadowHeight = (int) (DEFAULT_SHADOW_HEIGHT * density + 0.5f); } if (mParallaxOffset == -1) { mParallaxOffset = (int) (DEFAULT_PARALLAX_OFFSET * density); } // If the shadow height is zero, don't show the shadow if (mShadowHeight > 0) { if (mIsSlidingUp) { mShadowDrawable = ContextCompat.getDrawable(context, R.drawable.sliding_panel_above_shadow); } else { mShadowDrawable = ContextCompat.getDrawable(context, R.drawable.sliding_panel_below_shadow); } } else { mShadowDrawable = null; } setWillNotDraw(false); mDragHelper = ViewDragHelper.create(this, 1.0f, new DragHelperCallback()); mDragHelper.setMinVelocity(mMinFlingVelocity * density); mCanSlide = true; mIsSlidingEnabled = true; ViewConfiguration vc = ViewConfiguration.get(context); mScrollTouchSlop = vc.getScaledTouchSlop(); }
From source file:com.aidy.bottomdrawerlayout.AllDrawerLayout.java
public AllDrawerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); final float density = getResources().getDisplayMetrics().density; mMinDrawerMargin = (int) (MIN_DRAWER_MARGIN * density + 0.5f); final float minVel = MIN_FLING_VELOCITY * density; mLeftCallback = new ViewDragCallback(Gravity.LEFT); mRightCallback = new ViewDragCallback(Gravity.RIGHT); mTopCallback = new ViewDragCallback(Gravity.TOP); mBottomCallback = new ViewDragCallback(Gravity.BOTTOM); mLeftDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mLeftCallback); mLeftDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_LEFT); mLeftDragger.setMinVelocity(minVel); mLeftCallback.setDragger(mLeftDragger); mRightDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mRightCallback); mRightDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_RIGHT); mRightDragger.setMinVelocity(minVel); mRightCallback.setDragger(mRightDragger); mTopDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mTopCallback); mTopDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_TOP); mTopDragger.setMinVelocity(minVel);/*from ww w. j a v a 2 s . c o m*/ mTopCallback.setDragger(mTopDragger); mBottomDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mBottomCallback); mBottomDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_BOTTOM); mBottomDragger.setMinVelocity(minVel); mBottomCallback.setDragger(mBottomDragger); // So that we can catch the back button setFocusableInTouchMode(true); ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegate()); ViewGroupCompat.setMotionEventSplittingEnabled(this, false); }
From source file:com.licubeclub.zionhs.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Calendar Cal = Calendar.getInstance(); AMorPM = Cal.get(Calendar.AM_PM); DAYofWEEK = Cal.get(Calendar.DAY_OF_WEEK); DAYofMONTH = Cal.get(Calendar.DAY_OF_MONTH); Log.d("DAYofMONTH", String.valueOf(Cal.get(Calendar.DAY_OF_MONTH))); cManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); mobile = cManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); wifi = cManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); setContentView(R.layout.activity_main); /*/* w w w . ja v a 2s . c om*/ * TODO - ? (/?/?) * */ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); MEAL = (TextView) findViewById(R.id.mealdata); SCHEDULE = (TextView) findViewById(R.id.schedata); NOTIPARNTS = (TextView) findViewById(R.id.notiparentdata); NOTICES = (TextView) findViewById(R.id.notidata); View notices = findViewById(R.id.notices); View meal = findViewById(R.id.meal); View schedule = findViewById(R.id.schedule); View notices_parents = findViewById(R.id.notices_parents); notices.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent0 = new Intent(MainActivity.this, Notices.class); intent0.putExtra("url", "http://www.zion.hs.kr/main.php?menugrp=110100&master=bbs&act=list&master_sid=58"); intent0.putExtra("title", getResources().getString(R.string.notices)); startActivity(intent0); } }); meal.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(MainActivity.this, MealActivity.class); startActivity(intent); } }); schedule.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(MainActivity.this, Schedule.class); startActivity(intent); } }); notices_parents.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(MainActivity.this, Notices.class); intent.putExtra("url", "http://www.zion.hs.kr/main.php?menugrp=110200&master=bbs&act=list&master_sid=59"); intent.putExtra("title", getResources().getString(R.string.title_activity_notices__parents)); startActivity(intent); } }); //Navigation Drawer DrawerArray = new ArrayList<String>(); DrawerArray.add(getString(R.string.meal)); DrawerArray.add(getString(R.string.schedule)); DrawerArray.add(getString(R.string.title_activity_notices__parents)); DrawerArray.add(getString(R.string.notices)); DrawerArray.add(getString(R.string.schoolintro)); DrawerArray.add(getString(R.string.schoolinfo)); DrawerArray.add(getString(R.string.appsettings_apinfo_title)); IconArray = new ArrayList<Drawable>(); IconArray.add(getResources().getDrawable(R.drawable.ic_meal)); IconArray.add(getResources().getDrawable(R.drawable.ic_event_black_24dp)); IconArray.add(getResources().getDrawable(R.drawable.ic_insert_drive_file_black_24dp)); IconArray.add(getResources().getDrawable(R.drawable.ic_speaker_notes_black_24dp)); IconArray.add(getResources().getDrawable(R.drawable.ic_intro)); IconArray.add(getResources().getDrawable(R.drawable.ic_school)); IconArray.add(getResources().getDrawable(R.drawable.ic_info_black_24dp)); NavigationDrawer = (DrawerLayout) findViewById(R.id.drawer_layout); DrawerList = (ListView) findViewById(R.id.left_drawer); Adapter = new DrawerListAdapter(this, DrawerArray, IconArray); DrawerList.setAdapter(Adapter); //Listen for Navigation Drawer State DrawerToggle = new ActionBarDrawerToggle(this, NavigationDrawer, R.string.drawer_open, R.string.drawer_close) { /** Called when a drawer has settled in a completely closed state. */ public void onDrawerClosed(View view) { super.onDrawerClosed(view); isNavDrawerOpen = false; } /** Called when a drawer has settled in a completely open state. */ public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); // getSupportActionBar().setBackgroundDrawable(Darkblue); isNavDrawerOpen = true; } }; NavigationDrawer.setDrawerListener(DrawerToggle); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); //Drawer Item Click action DrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: startActivity(new Intent(MainActivity.this, MealActivity.class)); break; case 1: startActivity(new Intent(MainActivity.this, Schedule.class)); break; case 2: Intent intent = new Intent(MainActivity.this, Notices.class); intent.putExtra("url", "http://www.zion.hs.kr/main.php?menugrp=110200&master=bbs&act=list&master_sid=59"); intent.putExtra("title", getResources().getString(R.string.title_activity_notices__parents)); startActivity(intent); break; case 3: Intent intent0 = new Intent(MainActivity.this, Notices.class); intent0.putExtra("url", "http://www.zion.hs.kr/main.php?menugrp=110100&master=bbs&act=list&master_sid=58"); intent0.putExtra("title", getResources().getString(R.string.notices)); startActivity(intent0); break; case 4: startActivity(new Intent(MainActivity.this, Schoolintro.class)); break; case 5: startActivity(new Intent(MainActivity.this, Schoolinfo.class)); break; case 6: startActivity(new Intent(MainActivity.this, Appinfo.class)); break; } } }); SRL = (SwipeRefreshLayout) findViewById(R.id.swiperefresh); if (mobile.isConnected() || wifi.isConnected()) { networkTask(); } else { Toast toast = Toast.makeText(getApplicationContext(), getResources().getString(R.string.network_connection_warning), Toast.LENGTH_LONG); toast.setGravity(Gravity.BOTTOM, 0, 0); toast.show(); } SRL.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { cManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); mobile = cManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); wifi = cManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); if (mobile.isConnected() || wifi.isConnected()) { networkTask(); } else { Toast toast = Toast.makeText(getApplicationContext(), getResources().getString(R.string.network_connection_warning), Toast.LENGTH_LONG); toast.setGravity(Gravity.BOTTOM, 0, 0); toast.show(); SRL.setRefreshing(false); } } }); }
From source file:com.givon.anhao.activity.AnhaoMainActivity.java
/** * ?/* ww w . j a v a2 s.c om*/ */ private void initView() { unreadLabel = (TextView) findViewById(R.id.unread_msg_number); unreadAddressLable = (TextView) findViewById(R.id.unread_address_number); mSlideMenu = new SlideMenu(this); mSlideMenu.setBackground(R.drawable.chat_bg); mSlideMenu.attachToActivity(this); mItemHome = new SlideMenuItem(this, R.drawable.ic_home_home, ""); mItemSet = new SlideMenuItem(this, R.drawable.ic_home_yugao, ""); mSlideMenu.setoClickHeaderListener(new onClickHeaderListener() { @Override public void onClick(View v) { // ? getPopupWindowInstance(); mPopupWindow.showAtLocation(v, Gravity.BOTTOM, 0, 0); } }); MenuClickListener listener = new MenuClickListener(); mItemHome.setOnClickListener(listener); mItemSet.setOnClickListener(listener); mSlideMenu.addMenuItem(mItemHome); mSlideMenu.addMenuItem(mItemSet); }
From source file:com.aidy.bottomdrawerlayout.BottomDrawerLayout.java
/** * Enable or disable interaction with all drawers. * //from w w w . j a va 2s .c o m * <p> * This allows the application to restrict the user's ability to open or * close any drawer within this layout. DrawerLayout will still respond to * calls to {@link #openDrawer(int)}, {@link #closeDrawer(int)} and friends * if a drawer is locked. * </p> * * <p> * Locking drawers open or closed will implicitly open or close any drawers * as appropriate. * </p> * * @param lockMode * The new lock mode for the given drawer. One of * {@link #LOCK_MODE_UNLOCKED}, {@link #LOCK_MODE_LOCKED_CLOSED} * or {@link #LOCK_MODE_LOCKED_OPEN}. */ public void setDrawerLockMode(int lockMode) { setDrawerLockMode(lockMode, Gravity.BOTTOM); }
From source file:com.amitupadhyay.aboutexample.ui.widget.CollapsingTitleLayout.java
private void recalculate(int width) { // reset stateful objects that might change over measure passes paint.setTextSize(collapsedTextSize); displayText = new SpannableStringBuilder(title); // Calculate line height; ensure it' a multiple of 4dp to sit on the grid final float fourDip = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics()); Paint.FontMetricsInt fm = paint.getFontMetricsInt(); int fontHeight = Math.abs(fm.ascent - fm.descent) + fm.leading; final int baselineAlignedLineHeight = (int) (fourDip * (float) Math.ceil(lineHeightHint / fourDip)); lineSpacingAdd = Math.max(0, baselineAlignedLineHeight - fontHeight); // now create the layout with our desired insets & line height createLayout(width, lineSpacingAdd); // adjust the title top inset to vertically center text with the toolbar collapsedHeight = (int) Math.max(ViewUtils.getActionBarSize(getContext()), (fourDip + baselineAlignedLineHeight + fourDip)); titleInsetTop = (collapsedHeight - baselineAlignedLineHeight) / 2f; if (lineCount == 1) { // single line mode layout = null;//from www.j a v a 2 s . c om collapsingText = new CollapsingTextHelper(this); collapsingText.setText(title); collapsingText.setCollapsedBounds(titleInsetStart, 0, width - titleInsetEnd, (int) collapsedHeight); collapsingText.setExpandedBounds(titleInsetStart, (int) titleInsetTop, width - titleInsetEnd, getMinimumHeight() - titleInsetBottom); collapsingText.setCollapsedTextColor(paint.getColor()); collapsingText.setExpandedTextColor(paint.getColor()); collapsingText.setCollapsedTextSize(collapsedTextSize); int expandedTitleTextSize = (int) Math.max(collapsedTextSize, ViewUtils.getSingleLineTextSize(displayText.toString(), paint, width - titleInsetStart - titleInsetEnd, collapsedTextSize, maxExpandedTextSize, 0.5f, getResources().getDisplayMetrics())); collapsingText.setExpandedTextSize(expandedTitleTextSize); collapsingText.setExpandedTextGravity(GravityCompat.START | Gravity.BOTTOM); collapsingText.setCollapsedTextGravity(GravityCompat.START | Gravity.CENTER_VERTICAL); collapsingText.setTypeface(paint.getTypeface()); textTop = getHeight() - titleInsetBottom - fontHeight; scrollRange = getMinimumHeight() - (int) collapsedHeight; } else { // multi-line mode // bottom align the text textTop = getDesiredHeight() - titleInsetBottom - layout.getHeight(); // pre-calculate at what scroll offsets lines should disappear scrollRange = (int) (textTop - titleInsetTop); final int fadeDistance = layout.getLineBottom(0) - layout.getLineBaseline(0); lines = new Line[lineCount]; for (int i = 1; i < lineCount; i++) { int lineBottomScrollOffset = scrollRange + ((lineCount - i - 1) * baselineAlignedLineHeight); lines[i] = new Line(layout.getLineStart(i), layout.getLineEnd(i), new TextColorSpan(paint.getColor()), lineBottomScrollOffset, lineBottomScrollOffset + fadeDistance); } } calculatedWithWidth = width; }
From source file:com.actionbarsherlock.custom.widget.VerticalDrawerLayout.java
/** * Set a simple drawable used for the left or right shadow. * The drawable provided must have a nonzero intrinsic width. * * @param shadowDrawable Shadow drawable to use at the edge of a drawer * @param gravity Which drawer the shadow should apply to *///ww w . j a v a 2s . co m public void setDrawerShadow(Drawable shadowDrawable, int gravity) { /* * TODO Someone someday might want to set more complex drawables here. * They're probably nuts, but we might want to consider registering callbacks, * setting states, etc. properly. */ final int absGravity = GravityCompat.getAbsoluteGravity(gravity, ViewCompat.getLayoutDirection(this)); if ((absGravity & Gravity.TOP) == Gravity.TOP) { mShadowTop = shadowDrawable; invalidate(); } if ((absGravity & Gravity.BOTTOM) == Gravity.BOTTOM) { mShadowBottom = shadowDrawable; invalidate(); } }
From source file:com.jaredrummler.android.colorpicker.ColorPanelView.java
/** * Show a toast message with the hex color code below the view. *//* w w w . ja va 2s .c o m*/ public void showHint() { final int[] screenPos = new int[2]; final Rect displayFrame = new Rect(); getLocationOnScreen(screenPos); getWindowVisibleDisplayFrame(displayFrame); final Context context = getContext(); final int width = getWidth(); final int height = getHeight(); final int midy = screenPos[1] + height / 2; int referenceX = screenPos[0] + width / 2; if (ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_LTR) { final int screenWidth = context.getResources().getDisplayMetrics().widthPixels; referenceX = screenWidth - referenceX; // mirror } StringBuilder hint = new StringBuilder("#"); if (Color.alpha(color) != 255) { hint.append(Integer.toHexString(color).toUpperCase(Locale.ENGLISH)); } else { hint.append(String.format("%06X", 0xFFFFFF & color).toUpperCase(Locale.ENGLISH)); } Toast cheatSheet = Toast.makeText(context, hint.toString(), Toast.LENGTH_SHORT); if (midy < displayFrame.height()) { // Show along the top; follow action buttons cheatSheet.setGravity(Gravity.TOP | GravityCompat.END, referenceX, screenPos[1] + height - displayFrame.top); } else { // Show along the bottom center cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, height); } cheatSheet.show(); }
From source file:com.tmall.ultraviewpager.sample.PagerActivity.java
/** * *///from ww w . j a va 2 s. com private void defaultUltraViewPager() { UltraViewPager ultraViewPager = (UltraViewPager) findViewById(R.id.ultra_viewpager); ultraViewPager.setScrollMode(UltraViewPager.ScrollMode.HORIZONTAL); //initialize UltraPagerAdapterand add child view to UltraViewPager PagerAdapter adapter = new UltraPagerAdapter(false); ultraViewPager.setAdapter(adapter); //initialize built-in indicator ultraViewPager.initIndicator(); //set style of indicators ultraViewPager.getIndicator().setOrientation(UltraViewPager.Orientation.HORIZONTAL) .setFocusColor(Color.GREEN).setNormalColor(Color.WHITE).setRadius((int) TypedValue .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, getResources().getDisplayMetrics())); //set the alignment ultraViewPager.getIndicator().setGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM); //construct built-in indicator, and add it to UltraViewPager ultraViewPager.getIndicator().build(); //set an infinite loop ultraViewPager.setInfiniteLoop(true); //enable auto-scroll mode ultraViewPager.setAutoScroll(2000); }