Example usage for android.view Gravity TOP

List of usage examples for android.view Gravity TOP

Introduction

In this page you can find the example usage for android.view Gravity TOP.

Prototype

int TOP

To view the source code for android.view Gravity TOP.

Click Source Link

Document

Push object to the top of its container, not changing its size.

Usage

From source file:android.support.transition.SidePropagation.java

private int distance(View sceneRoot, int viewX, int viewY, int epicenterX, int epicenterY, int left, int top,
        int right, int bottom) {
    final int side;
    if (mSide == Gravity.START) {
        final boolean isRtl = ViewCompat.getLayoutDirection(sceneRoot) == ViewCompat.LAYOUT_DIRECTION_RTL;
        side = isRtl ? Gravity.RIGHT : Gravity.LEFT;
    } else if (mSide == Gravity.END) {
        final boolean isRtl = ViewCompat.getLayoutDirection(sceneRoot) == ViewCompat.LAYOUT_DIRECTION_RTL;
        side = isRtl ? Gravity.LEFT : Gravity.RIGHT;
    } else {/*  w  w  w  .  jav  a 2 s.co  m*/
        side = mSide;
    }
    int distance = 0;
    switch (side) {
    case Gravity.LEFT:
        distance = right - viewX + Math.abs(epicenterY - viewY);
        break;
    case Gravity.TOP:
        distance = bottom - viewY + Math.abs(epicenterX - viewX);
        break;
    case Gravity.RIGHT:
        distance = viewX - left + Math.abs(epicenterY - viewY);
        break;
    case Gravity.BOTTOM:
        distance = viewY - top + Math.abs(epicenterX - viewX);
        break;
    }
    return distance;
}

From source file:com.linkbubble.ui.BubbleFlowDraggable.java

public void configure(EventHandler eventHandler, boolean addRootWindow) {
    mUrlsToOpen = new HashSet<OpenUrlSettings>();
    mUrlsToOpenLock = new ReentrantReadWriteLock();
    mBubbleFlowWidth = Config.mScreenWidth;
    mBubbleFlowHeight = getResources().getDimensionPixelSize(R.dimen.bubble_pager_height);

    configure(mBubbleFlowWidth, getResources().getDimensionPixelSize(R.dimen.bubble_pager_item_width),
            getResources().getDimensionPixelSize(R.dimen.bubble_pager_item_height));

    setBubbleFlowViewListener(new BubbleFlowView.Listener() {
        @Override/*from w w w.  j  ava2  s  .c  o  m*/
        public void onCenterItemClicked(BubbleFlowView sender, View view) {
            try {
                MainController.get().switchToBubbleView();
            } catch (NullPointerException exc) {
                CrashTracking.logHandledException(exc);
            }
        }

        @Override
        public void onCenterItemLongClicked(BubbleFlowView sender, View view) {
            if (view instanceof TabView) {
                MainController mainController = MainController.get();
                if (mainController.getActiveTabCount() != 0) {
                    mainController.startDraggingFromContentView();
                }
            }
        }

        @Override
        public void onCenterItemSwiped(VerticalGestureListener.GestureDirection gestureDirection) {
            // TODO: Implement me
        }

        @Override
        public void onCenterItemChanged(BubbleFlowView sender, View view) {
            setCurrentTab((TabView) view, true);
        }
    });

    WindowManager.LayoutParams windowManagerParams = new WindowManager.LayoutParams();
    windowManagerParams.gravity = Gravity.TOP | Gravity.LEFT;
    windowManagerParams.x = 0;
    windowManagerParams.y = 0;
    windowManagerParams.height = mBubbleFlowHeight;
    windowManagerParams.width = mBubbleFlowWidth;
    windowManagerParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
    windowManagerParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
            | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
            | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
    windowManagerParams.format = PixelFormat.TRANSPARENT;
    windowManagerParams.setTitle("LinkBubble: BubbleFlowView");

    mDraggableHelper = new DraggableHelper(this, windowManagerParams, false,
            new DraggableHelper.OnTouchActionEventListener() {

                @Override
                public void onActionDown(DraggableHelper.TouchEvent event) {
                    if (mEventHandler != null) {
                        mEventHandler.onMotionEvent_Touch(BubbleFlowDraggable.this, event);
                    }
                }

                @Override
                public void onActionMove(DraggableHelper.MoveEvent event) {
                    if (mEventHandler != null) {
                        mEventHandler.onMotionEvent_Move(BubbleFlowDraggable.this, event);
                    }
                }

                @Override
                public void onActionUp(DraggableHelper.ReleaseEvent event, boolean startDelay) {
                    if (mEventHandler != null) {
                        mEventHandler.onMotionEvent_Release(BubbleFlowDraggable.this, event);
                    }
                }
            });

    mEventHandler = eventHandler;

    if (mDraggableHelper.isAlive() && addRootWindow) {
        MainController.addRootWindow(this, windowManagerParams);

        setExactPos(0, 0);
    }
    mDestroyed = false;
    StartActivity();
}

From source file:com.doomy.library.Internal.PopupIndicator.java

private WindowManager.LayoutParams createPopupLayout(IBinder token) {
    WindowManager.LayoutParams p = new WindowManager.LayoutParams();
    p.gravity = Gravity.START | Gravity.TOP;
    p.width = ViewGroup.LayoutParams.MATCH_PARENT;
    p.height = ViewGroup.LayoutParams.MATCH_PARENT;
    p.format = PixelFormat.TRANSLUCENT;// w ww.j a  va  2  s. c  o m
    p.flags = computeFlags(p.flags);
    p.type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;
    p.token = token;
    p.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN;
    p.setTitle("DiscreteSeekBar Indicator:" + Integer.toHexString(hashCode()));

    return p;
}

From source file:at.andreasrohner.spartantimelapserec.BackgroundService.java

@SuppressWarnings("deprecation")
@Override/*from  w w  w  .j  a va 2s .  c o m*/
public void onCreate() {
    created = true;

    settings = new RecSettings();
    settings.load(getApplicationContext(),
            PreferenceManager.getDefaultSharedPreferences(getApplicationContext()));

    createNotification(NOTIFICATION_ID);

    if (settings.isSchedRecEnabled() && settings.getSchedRecTime() > System.currentTimeMillis() + 10000) {
        AlarmManager alarmMgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
        Intent intent = new Intent(getApplicationContext(), ScheduleReceiver.class);
        PendingIntent alarmIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, intent, 0);

        alarmMgr.set(AlarmManager.RTC_WAKEUP, settings.getSchedRecTime(), alarmIntent);

        stopSelf();
        return;
    }

    // Create new SurfaceView, set its size to 1x1, move
    // it to the top left corner and set this service as a callback
    WindowManager winMgr = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    surfaceView = new SurfaceView(this);
    // deprecated setting, but required on Android versions prior to 3.0
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB)
        surfaceView.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    surfaceView.getHolder().addCallback(this);

    LayoutParams layoutParams = new WindowManager.LayoutParams(1, 1,
            WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
            PixelFormat.TRANSLUCENT);
    layoutParams.gravity = Gravity.LEFT | Gravity.TOP;
    winMgr.addView(surfaceView, layoutParams);

    PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
    wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
    wakeLock.setReferenceCounted(false);
    wakeLock.acquire();
}

From source file:com.scoreflex.ScoreflexView.java

/**
 * The constructor of the view./*from w w w .  j  a v  a  2s  . c o m*/
 * @param activity The activity holding the view.
 * @param attrs
 * @param defStyle
 */
@SuppressWarnings("deprecation")
public ScoreflexView(Activity activity, AttributeSet attrs, int defStyle) {
    super(activity, attrs, defStyle);

    // Keep a reference on the activity
    mParentActivity = activity;

    // Default layout params
    if (null == getLayoutParams()) {
        setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                Scoreflex.getDensityIndependantPixel(R.dimen.scoreflex_panel_height)));
    }

    // Set our background color
    setBackgroundColor(getContext().getResources().getColor(R.color.scoreflex_background_color));

    // Create the top bar
    View topBar = new View(getContext());
    topBar.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            getResources().getDimensionPixelSize(R.dimen.scoreflex_topbar_height), Gravity.TOP));
    topBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.scoreflex_gradient_background));
    addView(topBar);

    // Create the retry button
    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    mErrorLayout = (ViewGroup) inflater.inflate(R.layout.scoreflex_error_layout, null);
    if (mErrorLayout != null) {

        // Configure refresh button
        Button refreshButton = (Button) mErrorLayout.findViewById(R.id.scoreflex_retry_button);
        if (null != refreshButton) {
            refreshButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View arg0) {
                    if (null == Scoreflex.getPlayerId()) {
                        setUserInterfaceState(new LoadingState());
                        loadUrlAfterLoggedIn(mInitialResource, mInitialRequestParams);
                    } else if (null == mWebView.getUrl()) {
                        setResource(mInitialResource);
                    } else {
                        mWebView.reload();
                    }
                }
            });
        }

        // Configure cancel button
        Button cancelButton = (Button) mErrorLayout.findViewById(R.id.scoreflex_cancel_button);
        if (null != cancelButton) {
            cancelButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View arg0) {
                    close();
                }
            });
        }

        // Get hold of the message view
        mMessageView = (TextView) mErrorLayout.findViewById(R.id.scoreflex_error_message_view);
        addView(mErrorLayout);

    }

    // Create the close button
    mCloseButton = new ImageButton(getContext());
    Drawable closeButtonDrawable = getResources().getDrawable(R.drawable.scoreflex_close_button);
    int closeButtonMargin = (int) ((getResources().getDimensionPixelSize(R.dimen.scoreflex_topbar_height)
            - closeButtonDrawable.getIntrinsicHeight()) / 2.0f);
    FrameLayout.LayoutParams closeButtonLayoutParams = new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT,
            Gravity.TOP | Gravity.RIGHT);
    closeButtonLayoutParams.setMargins(0, closeButtonMargin, closeButtonMargin, 0);
    mCloseButton.setLayoutParams(closeButtonLayoutParams);
    mCloseButton.setImageDrawable(closeButtonDrawable);
    mCloseButton.setBackgroundDrawable(null);
    mCloseButton.setPadding(0, 0, 0, 0);
    mCloseButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            close();
        }
    });
    addView(mCloseButton);

    // Create the web view
    mWebView = new WebView(mParentActivity);
    mWebView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    // mWebView.setBackgroundColor(Color.RED);
    mWebView.setWebViewClient(new ScoreflexWebViewClient());
    mWebView.setWebChromeClient(new WebChromeClient() {

        @Override
        public boolean onConsoleMessage(ConsoleMessage cm) {
            Log.d("Scoreflex", "javascript Error: "
                    + String.format("%s @ %d: %s", cm.message(), cm.lineNumber(), cm.sourceId()));
            return true;
        }

        public void openFileChooser(ValueCallback<Uri> uploadMsg) {
            // mtbActivity.mUploadMessage = uploadMsg;
            mUploadMessage = uploadMsg;

            String fileName = "picture.jpg";
            ContentValues values = new ContentValues();
            values.put(MediaStore.Images.Media.TITLE, fileName);
            // mOutputFileUri = mParentActivity.getContentResolver().insert(
            // MediaStore.Images.Media.DATA, values);
            final List<Intent> cameraIntents = new ArrayList<Intent>();
            final Intent captureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            final PackageManager packageManager = mParentActivity.getPackageManager();
            final List<ResolveInfo> listCam = packageManager.queryIntentActivities(captureIntent, 0);
            for (ResolveInfo res : listCam) {
                final String packageName = res.activityInfo.packageName;
                final Intent intent = new Intent(captureIntent);
                intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name));
                intent.setPackage(packageName);
                cameraIntents.add(intent);
            }

            // Filesystem.
            final Intent galleryIntent = new Intent();
            galleryIntent.setType("image/*");
            galleryIntent.setAction(Intent.ACTION_GET_CONTENT);

            // Chooser of filesystem options.
            final Intent chooserIntent = Intent.createChooser(galleryIntent, "Select Source please");

            // Add the camera options.
            chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[] {}));

            mParentActivity.startActivityForResult(chooserIntent, Scoreflex.FILECHOOSER_RESULTCODE);
        }

        public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) {
            openFileChooser(uploadMsg);
        }

        public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
            openFileChooser(uploadMsg);
        }
    });
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setDomStorageEnabled(true);
    mWebView.getSettings().setDatabasePath(
            getContext().getFilesDir().getPath() + "/data/" + getContext().getPackageName() + "/databases/");
    addView(mWebView);

    TypedArray a = mParentActivity.obtainStyledAttributes(attrs, R.styleable.ScoreflexView, defStyle, 0);
    String resource = a.getString(R.styleable.ScoreflexView_resource);
    if (null != resource)
        setResource(resource);

    a.recycle();

    // Create the animated spinner

    mProgressBar = (ProgressBar) ((LayoutInflater) getContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.scoreflex_progress_bar, null);
    mProgressBar.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER));
    addView(mProgressBar);
    LocalBroadcastManager.getInstance(activity).registerReceiver(mLoginReceiver,
            new IntentFilter(Scoreflex.INTENT_USER_LOGED_IN));
    setUserInterfaceState(new InitialState());
}

From source file:com.gcssloop.diycode.activity.UserActivity.java

private void initScrollAnimation(ViewHolder holder) {
    NestedScrollView scrollView = holder.get(R.id.scroll_view);
    ImageView avatar = holder.get(R.id.avatar);
    TextView username = holder.get(R.id.username);
    View backbground = holder.get(R.id.background);

    this.expectAnimMove = new ExpectAnim().expect(avatar)
            .toBe(topOfParent().withMarginDp(13), leftOfParent().withMarginDp(13), scale(0.5f, 0.5f))
            .expect(username)/*from  ww  w  .  j av a  2  s. co m*/
            .toBe(toRightOf(avatar).withMarginDp(16), sameCenterVerticalAs(avatar), alpha(0.5f))
            .expect(backbground)
            .toBe(height(DensityUtils.dip2px(this, 60)).withGravity(Gravity.LEFT, Gravity.TOP)).toAnimation();

    scrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
        @Override
        public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX,
                int oldScrollY) {
            final float percent = (scrollY * 1f) / v.getMaxScrollAmount();
            expectAnimMove.setPercent(percent);
        }
    });
}

From source file:com.google.samples.apps.topeka.widget.quiz.AbsQuizView.java

private void addFloatingActionButton() {
    final int fabSize = getResources().getDimensionPixelSize(R.dimen.size_fab);
    int bottomOfQuestionView = findViewById(R.id.question_view).getBottom();
    final LayoutParams fabLayoutParams = new LayoutParams(fabSize, fabSize, Gravity.END | Gravity.TOP);
    final int halfAFab = fabSize / 2;
    fabLayoutParams.setMargins(0, // left
            bottomOfQuestionView - halfAFab, //top
            0, // right
            mSpacingDouble); // bottom
    MarginLayoutParamsCompat.setMarginEnd(fabLayoutParams, mSpacingDouble);
    if (ApiLevelHelper.isLowerThan(Build.VERSION_CODES.LOLLIPOP)) {
        // Account for the fab's emulated shadow.
        fabLayoutParams.topMargin -= (mSubmitAnswer.getPaddingTop() / 2);
    }/*www  .  j  av  a  2s.  c  om*/
    addView(mSubmitAnswer, fabLayoutParams);
}

From source file:com.rodrigopontes.androidbubbles.BubblesManager.java

/**
 * Adds new Bubble to BubblesManager/*from  w  w  w .  j  av a 2  s  . c o m*/
 */
public void addBubble(Bubble bubble) {
    if (windowManager != null) {
        WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.TYPE_PHONE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                        | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
                PixelFormat.TRANSLUCENT);
        params.gravity = Gravity.TOP | Gravity.START;
        params.y = screenHeight / BubblesProperties.BUBBLE_ENTER_Y_POSITION;
        BubbleController bubbleController = new BubbleController(bubble, params);
        bubble.getFrameLayout().setOnTouchListener(bubbleController.new BubbleTouchListener());
        bubblesList.add(bubbleController);
        windowManager.addView(bubble.getFrameLayout(), params);
        bubbleController.createdAnimation = new SpringAnimation(
                new AnimationPosition(BubblesProperties.MODE_STATIC_POSITION,
                        screenWidth + BubblesProperties.BUBBLE_ENTER_SPEED),
                new AnimationPosition(BubblesProperties.MODE_STATIC_POSITION, screenWidth
                        - (int) (bubbleController.bubbleWidth * BubblesProperties.BUBBLE_EDGE_OFFSET_RIGHT)),
                params, BubblesProperties.AXIS_X, BubblesProperties.SPRING_ANIMATION_LONG_DURATION, bubble)
                        .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    } else {
        throw new NullPointerException("BubblesManager has not yet been created! Use .create() first.");
    }
}

From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.AppStateObj.java

public void render(final Context context, final ViewGroup frame, Obj obj, boolean allowInteractions) {
    JSONObject content = obj.getJson();/*from w  ww.j a v  a 2  s  .c o  m*/
    // TODO: hack to show object history in app feeds
    JSONObject appState = getAppState(context, content);
    if (appState != null) {
        content = appState;
    } else {
        Log.e(TAG, "Missing inner content, probably because of format changes");
    }

    boolean rendered = false;
    AppState ref = new AppState(content);
    String thumbnail = ref.getThumbnailImage();
    if (thumbnail != null) {
        rendered = true;
        ImageView imageView = new ImageView(context);
        imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));
        App.instance().objectImages.lazyLoadImage(thumbnail.hashCode(), thumbnail, imageView);
        frame.addView(imageView);
    }

    thumbnail = ref.getThumbnailText();
    if (thumbnail != null) {
        rendered = true;
        TextView valueTV = new TextView(context);
        valueTV.setText(thumbnail);
        valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));
        valueTV.setGravity(Gravity.TOP | Gravity.LEFT);
        frame.addView(valueTV);
    }

    thumbnail = ref.getThumbnailHtml();
    if (thumbnail != null) {
        rendered = true;
        WebView webview = new WebView(context);
        webview.loadData(thumbnail, "text/html", "UTF-8");
        webview.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));
        Object o = frame.getTag(R.id.object_entry);
        webview.setOnTouchListener(new WebViewClickListener(frame, (Integer) o));
        frame.addView(webview);
    }

    if (!rendered) {
        String appName = content.optString(PACKAGE_NAME);
        if (appName.contains(".")) {
            appName = appName.substring(appName.lastIndexOf(".") + 1);
        }
        String text = "Welcome to " + appName + "!";
        TextView valueTV = new TextView(context);
        valueTV.setText(text);
        valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));
        valueTV.setGravity(Gravity.TOP | Gravity.LEFT);
        frame.addView(valueTV);
    }
}

From source file:com.duckduckgo.mobile.android.views.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}.//  ww w .  j  a v  a  2  s . c  o  m
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.TOP | Gravity.CENTER);
    textView.setTextAppearance(context, R.style.TabTitle);
    textView.setHeight((int) getResources().getDimension(R.dimen.actionbar_tab_height2));

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(true);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    int halfPadding = (int) (padding * 0.5);
    //textView.setPadding(padding, padding, padding, padding);
    textView.setPadding(padding, halfPadding, padding, padding);

    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = windowManager.getDefaultDisplay();
    int width;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
        Point size = new Point();
        display.getSize(size);
        width = size.x;
    } else {
        width = display.getWidth();
    }

    if (width > getResources().getDimension(R.dimen.tab_small)
            || getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        textView.setWidth(width / mViewPager.getAdapter().getCount());
    }

    return textView;
}