List of usage examples for android.view Gravity TOP
int TOP
To view the source code for android.view Gravity TOP.
Click Source Link
From source file:com.example.verticaldrawerlayout.VerticalDrawerLayout.java
public VerticalDrawerLayout(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; mTopCallback = new ViewDragCallback(Gravity.TOP); mBottomCallback = new ViewDragCallback(Gravity.BOTTOM); mTopDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mTopCallback); mTopDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_TOP); mTopDragger.setMinVelocity(minVel);//from w w w . j av a 2 s .co 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.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegate()); ViewGroupCompat.setMotionEventSplittingEnabled(this, false); }
From source file:ac.robinson.mediaphone.activity.NarrativeBrowserActivity.java
private void initialiseNarrativesView() { mScanningForNarratives = false;//w ww. ja v a2 s. c om mNarratives = (NarrativesListView) findViewById(R.id.list_narratives); // for API 11 and above, buttons are in the action bar if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { LayoutInflater layoutInflater = getLayoutInflater(); View headerRow = layoutInflater.inflate(R.layout.narratives_header, null, false); mNarratives.addHeaderView(headerRow, null, false); // false = not selectable View emptyView = layoutInflater.inflate(R.layout.narratives_empty, null, false); ((ViewGroup) mNarratives.getParent()).addView(emptyView); mNarratives.setEmptyView(emptyView); // must add separately as the header isn't shown when empty } else { // initial empty list placeholder - add manually as the < v11 version includes the header row TextView emptyView = new TextView(NarrativeBrowserActivity.this); emptyView.setGravity(Gravity.CENTER | Gravity.TOP); emptyView.setPadding(10, getResources().getDimensionPixelSize(R.dimen.narrative_list_empty_hint_top_padding), 10, 10); // temporary emptyView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); emptyView.setText(getString(R.string.narrative_list_empty)); ((ViewGroup) mNarratives.getParent()).addView(emptyView); mNarratives.setEmptyView(emptyView); } // originally used to fix selection highlights when using hardware button to select // now done by overriding isEnabled in NarrativeAdapter // mNarratives.setFocusable(false); // mNarratives.setFocusableInTouchMode(false); mNarrativeAdapter = new NarrativeAdapter(this, true, false); mNarratives.setAdapter(mNarrativeAdapter); getSupportLoaderManager().initLoader(R.id.loader_narratives_completed, null, this); mNarratives.setOnScrollListener(new ScrollManager()); mNarratives.setOnTouchListener(new FingerTracker()); mNarratives.setOnItemSelectedListener(new SelectionTracker()); mNarratives.setOnItemClickListener(new NarrativeViewer()); mPopupPosition = getLayoutInflater().inflate(R.layout.popup_position, null); mPopupText = (TextView) mPopupPosition.findViewById(R.id.popup_text); }
From source file:android.support.v7.widget.Toolbar.java
public Toolbar(Context context, AttributeSet attrs, int defStyleAttr) { // We manually themify the context here so that we don't break apps which only // use app:theme when running on >= Lollipop super(ViewUtils.themifyContext(context, attrs, false, true), attrs, defStyleAttr); // Need to use getContext() here so that we use the themed context final TintTypedArray a = TintTypedArray.obtainStyledAttributes(getContext(), attrs, R.styleable.Toolbar, defStyleAttr, 0);// w ww.jav a 2s. c o m mTitleTextAppearance = a.getResourceId(R.styleable.Toolbar_titleTextAppearance, 0); mSubtitleTextAppearance = a.getResourceId(R.styleable.Toolbar_subtitleTextAppearance, 0); mGravity = a.getInteger(R.styleable.Toolbar_android_gravity, mGravity); mButtonGravity = Gravity.TOP; mTitleMarginStart = mTitleMarginEnd = mTitleMarginTop = mTitleMarginBottom = a .getDimensionPixelOffset(R.styleable.Toolbar_titleMargins, 0); final int marginStart = a.getDimensionPixelOffset(R.styleable.Toolbar_titleMarginStart, -1); if (marginStart >= 0) { mTitleMarginStart = marginStart; } final int marginEnd = a.getDimensionPixelOffset(R.styleable.Toolbar_titleMarginEnd, -1); if (marginEnd >= 0) { mTitleMarginEnd = marginEnd; } final int marginTop = a.getDimensionPixelOffset(R.styleable.Toolbar_titleMarginTop, -1); if (marginTop >= 0) { mTitleMarginTop = marginTop; } final int marginBottom = a.getDimensionPixelOffset(R.styleable.Toolbar_titleMarginBottom, -1); if (marginBottom >= 0) { mTitleMarginBottom = marginBottom; } mMaxButtonHeight = a.getDimensionPixelSize(R.styleable.Toolbar_maxButtonHeight, -1); final int contentInsetStart = a.getDimensionPixelOffset(R.styleable.Toolbar_contentInsetStart, RtlSpacingHelper.UNDEFINED); final int contentInsetEnd = a.getDimensionPixelOffset(R.styleable.Toolbar_contentInsetEnd, RtlSpacingHelper.UNDEFINED); final int contentInsetLeft = a.getDimensionPixelSize(R.styleable.Toolbar_contentInsetLeft, 0); final int contentInsetRight = a.getDimensionPixelSize(R.styleable.Toolbar_contentInsetRight, 0); mContentInsets.setAbsolute(contentInsetLeft, contentInsetRight); if (contentInsetStart != RtlSpacingHelper.UNDEFINED || contentInsetEnd != RtlSpacingHelper.UNDEFINED) { mContentInsets.setRelative(contentInsetStart, contentInsetEnd); } mCollapseIcon = a.getDrawable(R.styleable.Toolbar_collapseIcon); mCollapseDescription = a.getText(R.styleable.Toolbar_collapseContentDescription); final CharSequence title = a.getText(R.styleable.Toolbar_title); if (!TextUtils.isEmpty(title)) { setTitle(title); } final CharSequence subtitle = a.getText(R.styleable.Toolbar_subtitle); if (!TextUtils.isEmpty(subtitle)) { setSubtitle(subtitle); } // Set the default context, since setPopupTheme() may be a no-op. mPopupContext = getContext(); setPopupTheme(a.getResourceId(R.styleable.Toolbar_popupTheme, 0)); final Drawable navIcon = a.getDrawable(R.styleable.Toolbar_navigationIcon); if (navIcon != null) { setNavigationIcon(navIcon); } final CharSequence navDesc = a.getText(R.styleable.Toolbar_navigationContentDescription); if (!TextUtils.isEmpty(navDesc)) { setNavigationContentDescription(navDesc); } // This is read for devices running pre-v16 mMinHeight = a.getDimensionPixelSize(R.styleable.Toolbar_android_minHeight, 0); a.recycle(); // Keep the TintManager in case we need it later mTintManager = a.getTintManager(); }
From source file:com.alburivan.slickform.tooltip.SimpleTooltip.java
private void configContentView() { if (mContentView instanceof TextView) { TextView tv = (TextView) mContentView; tv.setText(mText);// w w w .ja va 2s. co m } else { TextView tv = (TextView) mContentView.findViewById(mTextViewId); if (tv != null) tv.setText(mText); } mContentView.setPadding((int) mPadding, (int) mPadding, (int) mPadding, (int) mPadding); if (mShowArrow) { mArrowView = new ImageView(mContext); mArrowView.setImageDrawable(mArrowDrawable); LinearLayoutCompat.LayoutParams arrowLayoutParams; if (mGravity == Gravity.TOP || mGravity == Gravity.BOTTOM) { arrowLayoutParams = new LinearLayoutCompat.LayoutParams((int) mArrowWidth, (int) mArrowHeight, 0); } else { arrowLayoutParams = new LinearLayoutCompat.LayoutParams((int) mArrowHeight, (int) mArrowWidth, 0); } mArrowView.setLayoutParams(arrowLayoutParams); LinearLayoutCompat linearLayout = new LinearLayoutCompat(mContext); linearLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); linearLayout.setOrientation( mGravity == Gravity.START || mGravity == Gravity.END ? LinearLayoutCompat.HORIZONTAL : LinearLayoutCompat.VERTICAL); int padding = mAnimated ? mAnimationPadding : (int) SimpleTooltipUtils.pxFromDp(4); linearLayout.setPadding(padding, padding, padding, padding); if (mGravity == Gravity.TOP || mGravity == Gravity.START) { linearLayout.addView(mContentView); linearLayout.addView(mArrowView); } else { linearLayout.addView(mArrowView); linearLayout.addView(mContentView); } LinearLayoutCompat.LayoutParams contentViewParams = new LinearLayoutCompat.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0); contentViewParams.gravity = Gravity.CENTER; mContentView.setLayoutParams(contentViewParams); mContentLayout = linearLayout; } else { mContentLayout = mContentView; mContentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); } mContentLayout.setVisibility(View.INVISIBLE); mPopupWindow.setContentView(mContentLayout); }
From source file:alaindc.memenguage.View.MainActivity.java
private void updateWordsList() { wordsListview = (ListView) findViewById(R.id.wordslistview); adapter = new WordsAdapter(this, crs, 0); adapter.setFilterQueryProvider(new FilterQueryProvider() { public Cursor runQuery(CharSequence constraint) { return dbmanager.getMatchingWords(String.valueOf(constraint)); }//from ww w. ja va 2s . c o m }); wordsListview.setAdapter(adapter); wordsListview.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int pos, long id) { Intent createWordIntentActivity = new Intent(MainActivity.this, CreateEditActivity.class); createWordIntentActivity.setAction(Constants.ACTION_EDIT_WORD); Cursor crs = (Cursor) arg0.getItemAtPosition(pos); createWordIntentActivity.putExtra(Constants.EXTRA_EDIT_ITA, crs.getString(crs.getColumnIndex(Constants.FIELD_ITA))); createWordIntentActivity.putExtra(Constants.EXTRA_EDIT_ENG, crs.getString(crs.getColumnIndex(Constants.FIELD_ENG))); createWordIntentActivity.putExtra(Constants.EXTRA_EDIT_ID, id); MainActivity.this.startActivity(createWordIntentActivity); return true; } }); wordsListview.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int pos, long id) { crs = (Cursor) arg0.getItemAtPosition(pos); String text = "Memory level: " + crs.getInt(crs.getColumnIndex(Constants.FIELD_RATING)) + "/5"; text = text + "\nLast edit: " + Utils.getDate(crs.getLong(crs.getColumnIndex(Constants.FIELD_TIMESTAMP))); crs = dbmanager.getContextById(id); if (crs != null && crs.getCount() > 0) { crs.moveToFirst(); String cont = crs.getString(crs.getColumnIndex(Constants.FIELD_CONTEXT)); text = text + "\n\n" + ((cont.equals("")) ? "Add a context sentence" : "Context:\n" + cont); } Toast t = Toast.makeText(getApplicationContext(), text, Toast.LENGTH_LONG); t.setGravity(Gravity.TOP, 0, 250); t.show(); } }); //Toast.makeText(getApplicationContext(), adapter.getCount()+" words in Memenguage", Toast.LENGTH_SHORT).show(); }
From source file:com.google.android.apps.muzei.ArtDetailFragment.java
@Override public void onViewCreated(final View view, @Nullable final Bundle savedInstanceState) { mStatusBarScrimView = view.findViewById(R.id.statusbar_scrim); mChromeContainerView.setBackground(ScrimUtil.makeCubicGradientScrimDrawable(0xaa000000, 8, Gravity.BOTTOM)); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { mStatusBarScrimView.setVisibility(View.GONE); mStatusBarScrimView = null;//from w w w . j a va 2 s . com } else { mStatusBarScrimView.setBackground(ScrimUtil.makeCubicGradientScrimDrawable(0x44000000, 8, Gravity.TOP)); } mMetadataView = view.findViewById(R.id.metadata); final float metadataSlideDistance = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); mContainerView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() { @Override public void onSystemUiVisibilityChange(int vis) { final boolean visible = (vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) == 0; mChromeContainerView.setVisibility(View.VISIBLE); mChromeContainerView.animate().alpha(visible ? 1f : 0f) .translationY(visible ? 0 : metadataSlideDistance).setDuration(200) .withEndAction(new Runnable() { @Override public void run() { if (!visible) { mChromeContainerView.setVisibility(View.GONE); } } }); if (mStatusBarScrimView != null) { mStatusBarScrimView.setVisibility(View.VISIBLE); mStatusBarScrimView.animate().alpha(visible ? 1f : 0f).setDuration(200) .withEndAction(new Runnable() { @Override public void run() { if (!visible) { mStatusBarScrimView.setVisibility(View.GONE); } } }); } } }); mTitleView = (TextView) view.findViewById(R.id.title); mBylineView = (TextView) view.findViewById(R.id.byline); mAttributionView = (TextView) view.findViewById(R.id.attribution); final View overflowButton = view.findViewById(R.id.overflow_button); mOverflowMenu = new PopupMenu(getContext(), overflowButton); overflowButton.setOnTouchListener(mOverflowMenu.getDragToOpenListener()); overflowButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mOverflowMenu.show(); } }); mOverflowMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { int id = mOverflowSourceActionMap.get(menuItem.getItemId()); if (id > 0) { SourceManager.sendAction(getContext(), id); return true; } switch (menuItem.getItemId()) { case R.id.action_settings: FirebaseAnalytics.getInstance(getContext()).logEvent("settings_open", null); startActivity(new Intent(getContext(), SettingsActivity.class)); return true; } return false; } }); mNextButton = view.findViewById(R.id.next_button); mNextButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { SourceManager.sendAction(getContext(), MuzeiArtSource.BUILTIN_COMMAND_ID_NEXT_ARTWORK); mNextFakeLoading = true; showNextFakeLoading(); } }); CheatSheet.setup(mNextButton); mPanScaleProxyView = (PanScaleProxyView) view.findViewById(R.id.pan_scale_proxy); mPanScaleProxyView.setMaxZoom(5); mPanScaleProxyView.setOnViewportChangedListener(new PanScaleProxyView.OnViewportChangedListener() { @Override public void onViewportChanged() { if (mGuardViewportChangeListener) { return; } ArtDetailViewport.getInstance().setViewport(mCurrentViewportId, mPanScaleProxyView.getCurrentViewport(), true); } }); mPanScaleProxyView.setOnOtherGestureListener(new PanScaleProxyView.OnOtherGestureListener() { @Override public void onSingleTapUp() { showHideChrome((mContainerView.getSystemUiVisibility() & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0); } }); mLoadingContainerView = view.findViewById(R.id.image_loading_container); mLoadingIndicatorView = (AnimatedMuzeiLoadingSpinnerView) view.findViewById(R.id.image_loading_indicator); mLoadErrorContainerView = view.findViewById(R.id.image_error_container); mLoadErrorEasterEggView = view.findViewById(R.id.error_easter_egg); view.findViewById(R.id.image_error_retry_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { showNextFakeLoading(); getContext().startService(TaskQueueService.getDownloadCurrentArtworkIntent(getContext())); } }); }
From source file:android.support.v7ox.widget.Toolbar.java
public Toolbar(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); // Need to use getContext() here so that we use the themed context final TintTypedArray a = TintTypedArray.obtainStyledAttributes(getContext(), attrs, R.styleable.Toolbar, defStyleAttr, 0);/*from w w w. ja v a2 s .c o m*/ mTitleTextAppearance = a.getResourceId(R.styleable.Toolbar_titleTextAppearance, 0); mSubtitleTextAppearance = a.getResourceId(R.styleable.Toolbar_subtitleTextAppearance, 0); mGravity = a.getInteger(R.styleable.Toolbar_android_gravity, mGravity); mButtonGravity = Gravity.TOP; mTitleMarginStart = mTitleMarginEnd = mTitleMarginTop = mTitleMarginBottom = a .getDimensionPixelOffset(R.styleable.Toolbar_titleMargins, 0); final int marginStart = a.getDimensionPixelOffset(R.styleable.Toolbar_titleMarginStart, -1); if (marginStart >= 0) { mTitleMarginStart = marginStart; } final int marginEnd = a.getDimensionPixelOffset(R.styleable.Toolbar_titleMarginEnd, -1); if (marginEnd >= 0) { mTitleMarginEnd = marginEnd; } final int marginTop = a.getDimensionPixelOffset(R.styleable.Toolbar_titleMarginTop, -1); if (marginTop >= 0) { mTitleMarginTop = marginTop; } final int marginBottom = a.getDimensionPixelOffset(R.styleable.Toolbar_titleMarginBottom, -1); if (marginBottom >= 0) { mTitleMarginBottom = marginBottom; } mMaxButtonHeight = a.getDimensionPixelSize(R.styleable.Toolbar_maxButtonHeight, -1); final int contentInsetStart = a.getDimensionPixelOffset(R.styleable.Toolbar_contentInsetStart, RtlSpacingHelper.UNDEFINED); final int contentInsetEnd = a.getDimensionPixelOffset(R.styleable.Toolbar_contentInsetEnd, RtlSpacingHelper.UNDEFINED); final int contentInsetLeft = a.getDimensionPixelSize(R.styleable.Toolbar_contentInsetLeft, 0); final int contentInsetRight = a.getDimensionPixelSize(R.styleable.Toolbar_contentInsetRight, 0); mContentInsets.setAbsolute(contentInsetLeft, contentInsetRight); if (contentInsetStart != RtlSpacingHelper.UNDEFINED || contentInsetEnd != RtlSpacingHelper.UNDEFINED) { mContentInsets.setRelative(contentInsetStart, contentInsetEnd); } mCollapseIcon = a.getDrawable(R.styleable.Toolbar_collapseIcon); mCollapseDescription = a.getText(R.styleable.Toolbar_collapseContentDescription); final CharSequence title = a.getText(R.styleable.Toolbar_title); if (!TextUtils.isEmpty(title)) { setTitle(title); } final CharSequence subtitle = a.getText(R.styleable.Toolbar_subtitle); if (!TextUtils.isEmpty(subtitle)) { setSubtitle(subtitle); } // Set the default context, since setPopupTheme() may be a no-op. mPopupContext = getContext(); setPopupTheme(a.getResourceId(R.styleable.Toolbar_popupTheme, 0)); final Drawable navIcon = a.getDrawable(R.styleable.Toolbar_navigationIcon); if (navIcon != null) { setNavigationIcon(navIcon); } final CharSequence navDesc = a.getText(R.styleable.Toolbar_navigationContentDescription); if (!TextUtils.isEmpty(navDesc)) { setNavigationContentDescription(navDesc); } final Drawable logo = a.getDrawable(R.styleable.Toolbar_logo); if (logo != null) { setLogo(logo); } final CharSequence logoDesc = a.getText(R.styleable.Toolbar_logoDescription); if (!TextUtils.isEmpty(logoDesc)) { setLogoDescription(logoDesc); } if (a.hasValue(R.styleable.Toolbar_titleTextColor)) { setTitleTextColor(a.getColor(R.styleable.Toolbar_titleTextColor, 0xffffffff)); } if (a.hasValue(R.styleable.Toolbar_subtitleTextColor)) { setSubtitleTextColor(a.getColor(R.styleable.Toolbar_subtitleTextColor, 0xffffffff)); } a.recycle(); mDrawableManager = AppCompatDrawableManager.get(); }
From source file:com.justone.android.main.MainActivity.java
@SuppressWarnings("deprecation") @Override/*www . j a va 2s . com*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); currentContext = this; //listviewview this.viewMap = new HashMap<String, ListViewAdapter>(); // this.asynImageLoader = JustOne.getAsynImageLoader(); this.dataOp = JustOne.getDataOp(); // this.res = getResources(); // Resource object to get Drawables // StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites() .detectNetwork().penaltyLog().build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectLeakedSqlLiteObjects() .detectLeakedClosableObjects().penaltyLog().penaltyDeath().build()); justOne = (JustOne) getApplication(); justOne.pushActivity(this); // view LayoutInflater inflater = LayoutInflater.from(this); //details_page_setitem = inflater.inflate(R.layout.one_details_page_setitem, null); main_item = inflater.inflate(R.layout.activity_main, null); bind_item = inflater.inflate(R.layout.one_details_page_binditem, null); about_one = inflater.inflate(R.layout.about_one, null); //microblog = inflater.inflate(R.layout.one_details_page_microblog, null); feedback = inflater.inflate(R.layout.feedback, null); setContentView(main_item); initData(); // view mListView = (ListView) findViewById(R.id.tab2); //ArrayList<ArrayList<String>> list_data = loadData("list",data); listAdapter = new ListViewAdapter(this, mList, mGist, R.id.scrollview, R.layout.list_item); mListView.setAdapter(listAdapter); /* mListView1 = (ListView) findViewById(R.id.tab1); //ArrayList<ArrayList<String>> collect_data = loadData("collect",data); collectAdapter = new ListViewAdapter(this,mList, mGist, R.id.collectScrollview, R.layout.collect_item); mListView1.setAdapter(collectAdapter); */ homeListView = (ListView) findViewById(R.id.homeTab); homeAdapter = new ListViewAdapter(this, mList, mGist, R.id.homeScrollView, R.layout.home_item); homeListView.setAdapter(homeAdapter); qaListView = (ListView) findViewById(R.id.QAtab); //ArrayList<ArrayList<String>> QA_data = loadData("QA",data); QAAdapter = new ListViewAdapter(this, mList, mGist, R.id.qaScrollView, R.layout.qa_item); qaListView.setAdapter(QAAdapter); //detailView = (ListView) findViewById(R.id.tab3); //ArrayList<ArrayList<String>> detail_data = loadData("detail",data); //detailAdapter = new ListViewAdapter(this, // mList, mGist, // R.id.detailScrollView, R.layout.detail_item); //detailView.setAdapter(detailAdapter); /*//loading list view loadingView = (ListView) findViewById(R.id.loading_view); //ArrayList<ArrayList<String>> detail_data = loadData("detail",data); loadingAdapter = new ListViewAdapter(this, mList, mGist, R.id.loadingScrollView, R.layout.one_welcome_ad); loadingView.setAdapter(loadingAdapter); */ tabs = (TabHost) findViewById(R.id.tabhost); tabWidget = (TabWidget) findViewById(android.R.id.tabs); int width = 100; int height = 100; tabs.setup(); tabs.addTab(tabs.newTabSpec("home tab").setIndicator("", this.res.getDrawable(R.drawable.home_tab_selector)) .setContent(R.id.homeTab)); tabs.addTab(tabs.newTabSpec("list tab").setIndicator("", this.res.getDrawable(R.drawable.one_tab_selector)) .setContent(R.id.tab2)); tabs.addTab(tabs.newTabSpec("QA Tab").setIndicator("", this.res.getDrawable(R.drawable.qa_tab_selector)) .setContent(R.id.QAtab)); /* tabs.addTab(tabs.newTabSpec("second tab").setIndicator("", null) .setContent(R.id.tab1));*/ //tabs.addTab(tabs.newTabSpec("second tab").setIndicator("",this.res.getDrawable(R.drawable.more_tab_selector)) // .setContent(R.id.tab3)); tabs.setCurrentTab(0); for (int i = 0; i < tabWidget.getChildCount(); i++) { /** * fill_parent */ tabWidget.getChildAt(i).getLayoutParams().height = height; tabWidget.getChildAt(i).getLayoutParams().width = width; /** * tab */ final TextView tv = (TextView) tabWidget.getChildAt(i).findViewById(android.R.id.title); tv.setTextColor(this.getResources().getColorStateList(android.R.color.white)); tv.setTextSize(15); tv.setGravity(Gravity.TOP); } mActivityName = getString(R.string.activity_c_label); mStatusTracker.setStatus(mActivityName, getString(R.string.on_create)); Utils.printStatus(mStatusView, mStatusAllView); detector = new GestureDetector(this); viewMap.put("home", this.homeAdapter); // View returnBackToIndex = main_item.findViewById(R.id.returnBackToIndex_layout); returnBackToIndex.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { MainActivity.this.finish(); // TODO Auto-generated method stub } }); userFirstTips(); }
From source file:com.sender.team.sender.gcm.MyGcmListenerService.java
private void sendToast(final ChattingReceiveData data, final ChattingReceiveMessage c) { handler.post(new Runnable() { @Override// w ww . j a va2 s . com public void run() { View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.toast_notify, null); ImageView imageProfile = (ImageView) view.findViewById(R.id.imageProfile); TextView textName = (TextView) view.findViewById(R.id.textName); TextView textMessage = (TextView) view.findViewById(R.id.textMessage); Glide.with(getApplicationContext()).load(data.getSender().getFileUrl()).into(imageProfile); if (!TextUtils.isEmpty(data.getSender().getName())) { textName.setText(data.getSender().getName()); } if (!TextUtils.isEmpty(c.getMessage())) { textMessage.setText(c.getMessage()); } else { textMessage.setText(""); } Toast toast = new Toast(getApplicationContext()); float dp = 65; int pixel = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, getResources().getDisplayMetrics()); toast.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.TOP, 0, pixel); toast.setDuration(Toast.LENGTH_LONG); toast.setView(view); toast.show(); } }); }
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);//w w w .j ava2 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); }