Example usage for android.view Gravity CENTER_HORIZONTAL

List of usage examples for android.view Gravity CENTER_HORIZONTAL

Introduction

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

Prototype

int CENTER_HORIZONTAL

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

Click Source Link

Document

Place object in the horizontal center of its container, not changing its size.

Usage

From source file:org.bart452.runningshoesensor.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    requestPermission();/* w w w . j ava2  s.c  o m*/
    context = getApplicationContext();

    mHeaderImageView = (ImageView) findViewById(R.id.appBarIv);
    Picasso.with(context).load(R.drawable.sunset_road_landscape).into(mHeaderImageView);

    // Toolbar
    mToolbar = (Toolbar) findViewById(R.id.toolBar);
    setSupportActionBar(mToolbar);
    mCollapsingTb = (CollapsingToolbarLayout) findViewById(R.id.collapsingToolbar);
    mCollapsingTb.setTitle("Shoe sensor");
    mCollapsingTb.setExpandedTitleGravity(Gravity.CENTER_HORIZONTAL | Gravity.TOP);

    // Bluetooth
    final BluetoothManager mBleMan = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
    mBleAdapter = mBleMan.getAdapter();
    mBleScanner = mBleAdapter.getBluetoothLeScanner();
    mCharList = new ArrayList<>();
    mBleSem = new Semaphore(1);
    mBleThread = new BleThread(mBleSem);
    mBleThread.start();

    mBleReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(intent.getAction())) {
                if (mBleAdapter.getState() == BluetoothAdapter.STATE_ON) {
                    Log.d(LOG_TAG, "BT ON");
                    mScanFab.setEnabled(true);
                    if (mSnackBar != null) {
                        if (mSnackBar.isShown())
                            mSnackBar.dismiss();
                    }
                } else {
                    mScanFab.setEnabled(false);
                    bleEnable();
                }
            }
        }
    };

    // Text
    mDevNameTv = (TextView) findViewById(R.id.devNameTv);
    mDevNameTv.setText(getString(R.string.device_name) + " No device found");
    mRssiTv = (TextView) findViewById(R.id.rssiTv);
    mAddrTv = (TextView) findViewById(R.id.devAddrTv);

    // Buttons and switches
    mScanFab = (FloatingActionButton) findViewById(R.id.scanFab);
    mScanFab.setOnClickListener(this);
    mConnSwitch = (Switch) findViewById(R.id.connSwitch);
    mConnSwitch.setOnClickListener(this);

    //Graph
    mDataGraph = (GraphView) findViewById(R.id.dataGraph);
    mDataXSeries = new LineGraphSeries<>();
    mDataYSeries = new LineGraphSeries<>();
    mDataYSeries.setBackgroundColor(Color.RED);
    mDataGraph.addSeries(mDataXSeries);
    mDataGraph.addSeries(mDataYSeries);
    mDataGraph.getViewport().setXAxisBoundsManual(true);
    mDataGraph.getViewport().setMinX(0);
    mDataGraph.getViewport().setMaxX(20);

    // Animation
    mRotateAnim = new RotateAnimation(0, 720, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
            0.5f);
    mRotateAnim.setDuration(SCAN_PERIOD);
    mRotateAnim.setInterpolator(new LinearInterpolator());
    bleEnable();
}

From source file:cn.com.caronwer.activity.AuthSecondActivity.java

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.bt_ok:
        getImg();/*from   www  .  j av a 2 s. c  o m*/
        if (isCardNoImgSuccess && isDrivingLicenseImgSuccess && isCarHeadImgSuccess && isCarTailImgSuccess
                && isCarLeftImgSuccess && isCarRightImgSuccess) {
            uploadImg();
        } else {
            showShortToastByString("??");
        }
        break;
    case R.id.iv_left_white:
        finish();
        break;
    case R.id.upload_card_no:
    case R.id.card_no_img:
        imgType = 0;
        menuWindow = new SelectPicPopupWindow(AuthSecondActivity.this, itemsOnClick);
        menuWindow.showAtLocation(findViewById(R.id.auth_second), Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0,
                0);
        break;
    case R.id.upload_driving_license:
    case R.id.driving_license_img:
        imgType = 1;
        menuWindow = new SelectPicPopupWindow(AuthSecondActivity.this, itemsOnClick);
        menuWindow.showAtLocation(findViewById(R.id.auth_second), Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0,
                0);
        break;
    case R.id.upload_car_head:
    case R.id.car_head_img:
        imgType = 2;
        menuWindow = new SelectPicPopupWindow(AuthSecondActivity.this, itemsOnClick);
        menuWindow.showAtLocation(findViewById(R.id.auth_second), Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0,
                0);
        break;
    case R.id.upload_car_tail:
    case R.id.car_tail_img:
        imgType = 3;
        menuWindow = new SelectPicPopupWindow(AuthSecondActivity.this, itemsOnClick);
        menuWindow.showAtLocation(findViewById(R.id.auth_second), Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0,
                0);
        break;
    case R.id.upload_car_left:
    case R.id.car_left_img:
        imgType = 4;
        menuWindow = new SelectPicPopupWindow(AuthSecondActivity.this, itemsOnClick);
        menuWindow.showAtLocation(findViewById(R.id.auth_second), Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0,
                0);
        break;
    case R.id.upload_car_right:
    case R.id.car_right_img:
        imgType = 5;
        menuWindow = new SelectPicPopupWindow(AuthSecondActivity.this, itemsOnClick);
        menuWindow.showAtLocation(findViewById(R.id.auth_second), Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0,
                0);
        break;
    }
}

From source file:com.eeshana.icstories.activities.UploadVideoActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // this will copy the license file and the demo video file.
    // to the videokit work folder location.
    // without the license file the library will not work.
    //copyLicenseAndDemoFilesFromAssetsToSDIfNeeded();
    setContentView(R.layout.upload_video_activity);

    height = SignInActivity.getScreenHeight(UploadVideoActivity.this);
    width = SignInActivity.getScreenWidth(UploadVideoActivity.this);
    mProgressDialog = new ProgressDialog(UploadVideoActivity.this);
    pDialog = new ProgressDialog(UploadVideoActivity.this);
    showCustomToast = new ShowCustomToast();
    connectionDetector = new ConnectionDetector(UploadVideoActivity.this);
    //      mProgressDialog=new ProgressDialog(UploadVideoActivity.this,AlertDialog.THEME_HOLO_LIGHT);
    //      mProgressDialog.setFeatureDrawableResource(height,R.drawable.rounded_toast);
    prefs = getSharedPreferences("PREF", MODE_PRIVATE);
    regId = prefs.getString("regid", "NA");
    SharedPreferences pref = getSharedPreferences("DB", 0);
    userid = pref.getString("userid", "1");
    SharedPreferences assign_prefs = getSharedPreferences("ASSIGN", 0);
    assignment_id = assign_prefs.getString("ASSIGN_ID", "");
    videoPath = getIntent().getStringExtra("VIDEOPATH");

    //      iCTextView=(TextView) findViewById(R.id.tvIC);
    //      iCTextView.setTypeface(CaptureVideoActivity.ic_typeface,Typeface.BOLD);
    //      storiesTextView=(TextView) findViewById(R.id.tvStories);
    //      storiesTextView.setTypeface(CaptureVideoActivity.stories_typeface,Typeface.BOLD);
    //      watsStoryTextView=(TextView) findViewById(R.id.tvWhatsStory);
    //      watsStoryTextView.setTypeface(CaptureVideoActivity.stories_typeface,Typeface.ITALIC);

    //      logoImageView=(ImageView) findViewById(R.id.ivLogo);
    //      RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams((int) (width/1.9), (int) (height/9.5));
    //      lp.addRule(RelativeLayout.CENTER_HORIZONTAL);
    //      lp.setMargins(0, 0, 0, 0);
    //      logoImageView.setLayoutParams(lp);

    uploadtTextView = (TextView) findViewById(R.id.tvUpload);
    uploadtTextView.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD);
    //      extension=getIntent().getStringExtra("EXTENSION");
    //      folderPath = Environment.getExternalStorageDirectory().getPath()+"/ICStoriesFolder";
    //      if (!FileUtils.checkIfFolderExists(folderPath)) {
    //         boolean isFolderCreated = FileUtils.createFolder(folderPath);
    //         Log.i(Prefs.TAG, folderPath + " created? " + isFolderCreated);
    //         if (isFolderCreated) {
    ////  w  w w . j a  v  a2s.co  m
    //         }
    //      }
    //command for rotating video 90 degree
    //String commandStr="ffmpeg -y -i "+videoPath+" -strict experimental -vf transpose=1 -s 160x120 -r 30 -aspect 4:3 -ab 48000 -ac 2 -ar 22050 -b 2097k "+folderPath+"/out."+extension;

    //Change Video Resolution:
    //String commandStr="ffmpeg -y -i "+videoPath+" -strict experimental -vf transpose=3 -s 320x240 -r 15 -aspect 3:4 -ab 12288 -vcodec mpeg4 -b 2097152 -sample_fmt s16 "+folderPath+"/res."+extension;

    //command for compressing video 
    //      String commandStr="ffmpeg -y -i "+videoPath+" -strict experimental -s 320x240 -r 15 -aspect 3:4 -ab 12288 -vcodec mpeg4 -b 2097152 -sample_fmt s16 "+folderPath+"/test."+extension;
    //      setCommand(commandStr);
    //      runTranscoing();

    thumb = ThumbnailUtils.createVideoThumbnail(videoPath, MediaStore.Images.Thumbnails.MINI_KIND);
    System.out.println("THUMB IMG  in uplaod== " + thumb);

    titleEditText = (EditText) findViewById(R.id.etTitle);
    titleEditText.setTypeface(CaptureVideoActivity.stories_typeface);
    descriptionEditText = (EditText) findViewById(R.id.etDescripton);
    descriptionEditText.setTypeface(CaptureVideoActivity.stories_typeface);
    locationEditText = (EditText) findViewById(R.id.etLocation);
    locationEditText.setTypeface(CaptureVideoActivity.stories_typeface);
    isAssignmentButton = (Button) findViewById(R.id.buttonCheck);
    isAssignmentButton.setTypeface(CaptureVideoActivity.stories_typeface);
    isAssignmentButton.setOnClickListener(this);
    dailyAssignTextView = (TextView) findViewById(R.id.tvDailyAssignment);
    dailyAssignTextView.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD);
    uploadButton = (Button) findViewById(R.id.buttonUpload);
    uploadButton.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD);
    RelativeLayout uploadRelativeLayout = (RelativeLayout) findViewById(R.id.rlUpload);
    RelativeLayout.LayoutParams lp9 = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, height / 17);
    lp9.addRule(RelativeLayout.BELOW, R.id.rlDailyAssignment);
    lp9.setMargins(width / 7, 30, width / 7, 0);
    uploadRelativeLayout.setLayoutParams(lp9);
    uploadButton.setOnClickListener(this);

    //bottom bar

    homeRelativeLayout = (RelativeLayout) findViewById(R.id.rlHome);
    homeRelativeLayout.setBackgroundResource(R.drawable.press_border);
    homeRelativeLayout.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
    homeTextView = (TextView) homeRelativeLayout.findViewById(R.id.tvHome);
    homeTextView.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD);
    homeTextView.setTextColor(Color.parseColor("#fffffe"));
    RelativeLayout.LayoutParams lp4 = new RelativeLayout.LayoutParams(width / 3, width / 5);
    lp4.addRule(RelativeLayout.ALIGN_LEFT);
    homeRelativeLayout.setLayoutParams(lp4);
    homeRelativeLayout.setOnClickListener(this);

    wallRelativeLayout = (RelativeLayout) findViewById(R.id.rlWall);
    wallRelativeLayout.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
    wallTextView = (TextView) wallRelativeLayout.findViewById(R.id.tvWall);
    wallTextView.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD);
    RelativeLayout.LayoutParams lp5 = new RelativeLayout.LayoutParams(width / 3, width / 5);
    lp5.addRule(RelativeLayout.RIGHT_OF, R.id.rlHome);
    wallRelativeLayout.setLayoutParams(lp5);
    wallRelativeLayout.setOnClickListener(this);

    settingsRelativeLayout = (RelativeLayout) findViewById(R.id.rlSettings);
    settingsRelativeLayout.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
    settingsTextView = (TextView) settingsRelativeLayout.findViewById(R.id.tvSettings);
    settingsTextView.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD);
    RelativeLayout.LayoutParams lp6 = new RelativeLayout.LayoutParams(width / 3, width / 5);
    lp6.addRule(RelativeLayout.RIGHT_OF, R.id.rlWall);
    settingsRelativeLayout.setLayoutParams(lp6);
    settingsRelativeLayout.setOnClickListener(this);

    // current location
    locationDialog = new Dialog(UploadVideoActivity.this);
    locationDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    locationDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    locationDialog.setContentView(R.layout.location_dialog);
    locationDialog.setCancelable(true);
    LinearLayout dialogLayout = (LinearLayout) locationDialog.findViewById(R.id.ll1);
    okButton = (Button) dialogLayout.findViewById(R.id.OkBtn);
    okButton.setOnClickListener(this);
    cancelButton = (Button) dialogLayout.findViewById(R.id.cancelBtn);
    cancelButton.setOnClickListener(this);

    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    boolean network_enabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
    if (network_enabled) {
        locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);
    } else {
        showCustomToast.showToast(UploadVideoActivity.this,
                "Could not find current location. Please enable location services of your device.");
    }
    //      else if(gps_enabled == false){
    //         locationDialog.show();
    //      }
}

From source file:com.actionbarsherlock.internal.view.menu.ActionMenuItemView.java

@Override
public boolean onLongClick(View v) {
    if (hasText()) {
        // Don't show the cheat sheet for items that already show text.
        return false;
    }//from ww  w .java  2 s  . c  o m

    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;
    final int screenWidth = context.getResources().getDisplayMetrics().widthPixels;

    Toast cheatSheet = Toast.makeText(context, mItemData.getTitle(), Toast.LENGTH_SHORT);
    if (midy < displayFrame.height()) {
        // Show along the top; follow action buttons
        cheatSheet.setGravity(Gravity.TOP | Gravity.RIGHT, screenWidth - screenPos[0] - width / 2, height);
    } else {
        // Show along the bottom center
        cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, height);
    }
    cheatSheet.show();
    return true;
}

From source file:paulscode.android.mupen64plusae.profile.TouchscreenProfileActivity.java

@Override
protected void onResume() {
    super.onResume();

    // Refresh in case the global settings changed
    AppData appData = new AppData(this);
    mGlobalPrefs = new GlobalPrefs(this, appData);

    // Update the dummy GameSurface size in case global settings changed
    FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mSurface.getLayoutParams();
    params.gravity = mGlobalPrefs.displayPosition | Gravity.CENTER_HORIZONTAL;
    mSurface.setLayoutParams(params);//from  ww  w.j  a va2 s. c o m

    // Update the screen orientation in case global settings changed
    this.setRequestedOrientation(mGlobalPrefs.displayOrientation);

    // Refresh the touchscreen controls
    refresh();
}

From source file:com.npi.muzeiflickr.ui.activities.SettingsActivity.java

private void populateFooter(View footerView) {
    final View footerButton = footerView.findViewById(R.id.list_footer_button);
    final Spinner footerModeChooser = (Spinner) footerView.findViewById(R.id.mode_chooser);
    final RelativeLayout addItemContainer = (RelativeLayout) footerView.findViewById(R.id.new_item_container);
    final ImageButton footerSearchButton = (ImageButton) footerView.findViewById(R.id.footer_search_button);
    final ProgressBar footerProgress = (ProgressBar) footerView.findViewById(R.id.footer_progress);
    final EditText footerTerm = (EditText) footerView.findViewById(R.id.footer_term);

    footerButton.setOnLongClickListener(new View.OnLongClickListener() {
        @Override//from  w  w  w  .  ja v  a  2 s.  c o  m
        public boolean onLongClick(View v) {
            int[] pos = new int[2];
            footerButton.getLocationInWindow(pos);

            String contentDesc = footerButton.getContentDescription().toString();
            Toast t = Toast.makeText(SettingsActivity.this, contentDesc, Toast.LENGTH_SHORT);
            t.show();
            t.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, pos[1] + (footerButton.getHeight() / 2));

            return true;
        }
    });

    footerButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            addItemContainer.animate().alpha(1F);
            footerButton.animate().alpha(0F);
        }
    });

    //Mode spinner management
    ArrayAdapter<CharSequence> adapter = new SourceSpinnerAdapter(this, android.R.layout.simple_spinner_item,
            getResources().getStringArray(R.array.modes));

    footerModeChooser.setAdapter(adapter);

    footerSearchButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String searchString = footerTerm.getText().toString();
            switch (footerModeChooser.getSelectedItemPosition()) {
            case 0:

                //It's a search

                //Looking for a same existing search
                List<Search> searchs = Search.listAll(Search.class);
                for (Search search : searchs) {
                    if (search.getTitle().equals(searchString)) {
                        Toast.makeText(SettingsActivity.this, getString(R.string.search_exists),
                                Toast.LENGTH_LONG).show();
                        return;
                    }
                }

                footerSearchButton.setVisibility(View.GONE);
                footerProgress.setVisibility(View.VISIBLE);

                getSearch(searchString, new UserInfoListener<Search>() {
                    @Override
                    public void onSuccess(Search search) {
                        mRequestAdapter.add(search);
                        mRequestAdapter.notifyDataSetChanged();
                        footerSearchButton.setVisibility(View.VISIBLE);
                        footerProgress.setVisibility(View.GONE);
                        footerTerm.setText("");
                        footerModeChooser.setSelection(0);
                        addItemContainer.animate().alpha(0F);
                        footerButton.animate().alpha(1F);
                    }

                    @Override
                    public void onError(String reason) {
                        Toast.makeText(SettingsActivity.this, reason, Toast.LENGTH_LONG).show();
                        footerSearchButton.setVisibility(View.VISIBLE);
                        footerProgress.setVisibility(View.GONE);
                    }
                });

                break;
            case 1:
                //It's an user

                //Looking for a same existing search
                List<User> users = User.listAll(User.class);
                for (User user : users) {
                    if (user.getTitle().equals(searchString)) {
                        Toast.makeText(SettingsActivity.this, getString(R.string.user_exists),
                                Toast.LENGTH_LONG).show();
                        return;
                    }
                }

                footerSearchButton.setVisibility(View.GONE);
                footerProgress.setVisibility(View.VISIBLE);

                getUserId(searchString, new UserInfoListener<User>() {
                    @Override
                    public void onSuccess(User user) {
                        mRequestAdapter.add(user);
                        mRequestAdapter.notifyDataSetChanged();
                        footerSearchButton.setVisibility(View.VISIBLE);
                        footerProgress.setVisibility(View.GONE);
                        footerTerm.setText("");
                        footerModeChooser.setSelection(0);
                        addItemContainer.animate().alpha(0F);
                        footerButton.animate().alpha(1F);
                    }

                    @Override
                    public void onError(String reason) {
                        Toast.makeText(SettingsActivity.this, reason, Toast.LENGTH_LONG).show();
                        footerSearchButton.setVisibility(View.VISIBLE);
                        footerProgress.setVisibility(View.GONE);
                    }
                });
                break;
            case 2:
                //It's a tag

                //Looking for a same existing search
                List<Tag> tags = Tag.listAll(Tag.class);
                for (Tag tag : tags) {
                    if (tag.getTitle().equals(searchString)) {
                        Toast.makeText(SettingsActivity.this, getString(R.string.user_exists),
                                Toast.LENGTH_LONG).show();
                        return;
                    }
                }

                footerSearchButton.setVisibility(View.GONE);
                footerProgress.setVisibility(View.VISIBLE);

                getTag(searchString, new UserInfoListener<Tag>() {
                    @Override
                    public void onSuccess(Tag tag) {
                        mRequestAdapter.add(tag);
                        mRequestAdapter.notifyDataSetChanged();
                        footerSearchButton.setVisibility(View.VISIBLE);
                        footerProgress.setVisibility(View.GONE);
                        footerTerm.setText("");
                        footerModeChooser.setSelection(0);
                        addItemContainer.animate().alpha(0F);
                        footerButton.animate().alpha(1F);
                    }

                    @Override
                    public void onError(String reason) {
                        Toast.makeText(SettingsActivity.this, reason, Toast.LENGTH_LONG).show();
                        footerSearchButton.setVisibility(View.VISIBLE);
                        footerProgress.setVisibility(View.GONE);
                    }
                });
                break;

            case 3:
                //It's an user

                //Looking for a same existing search
                List<FGroup> groups = FGroup.listAll(FGroup.class);
                for (FGroup group : groups) {
                    if (group.getTitle().equals(searchString)) {
                        Toast.makeText(SettingsActivity.this, getString(R.string.group_exists),
                                Toast.LENGTH_LONG).show();
                        return;
                    }
                }

                footerSearchButton.setVisibility(View.GONE);
                footerProgress.setVisibility(View.VISIBLE);

                getGroupId(searchString, new UserInfoListener<FGroup>() {
                    @Override
                    public void onSuccess(FGroup group) {
                        mRequestAdapter.add(group);
                        mRequestAdapter.notifyDataSetChanged();
                        footerSearchButton.setVisibility(View.VISIBLE);
                        footerProgress.setVisibility(View.GONE);
                        footerTerm.setText("");
                        footerModeChooser.setSelection(0);
                        addItemContainer.animate().alpha(0F);
                        footerButton.animate().alpha(1F);
                    }

                    @Override
                    public void onError(String reason) {
                        Toast.makeText(SettingsActivity.this, reason, Toast.LENGTH_LONG).show();
                        footerSearchButton.setVisibility(View.VISIBLE);
                        footerProgress.setVisibility(View.GONE);
                    }
                });
                break;
            }
        }
    });
}

From source file:com.streaming.sweetplayer.MainActivity.java

private void adjustTabs() {
    if (mTabHost != null) {
        int tabHeight = 50;
        int tabsCount = mTabHost.getTabWidget().getTabCount();
        for (int i = 0; i < tabsCount; i++) {
            TextView tabTextView = (TextView) mTabHost.getTabWidget().getChildAt(i)
                    .findViewById(android.R.id.title);
            tabTextView.setTextSize(9);/*  ww  w .  j ava  2 s. c o m*/
            tabTextView.setPadding(2, 0, 2, 0);
            tabTextView.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
            mTabHost.getTabWidget().getChildAt(i)
                    .getLayoutParams().height = (int) (tabHeight * getResources().getDisplayMetrics().density);
        }
    }
}

From source file:xyz.berial.textinputlayout.CollapsingTextHelper.java

private void calculateBaseOffsets() {
    // We then calculate the collapsed text size, using the same logic
    mTextPaint.setTextSize(mCollapsedTextSize);
    float width = mTextToDraw != null ? mTextPaint.measureText(mTextToDraw, 0, mTextToDraw.length()) : 0;
    final int collapsedAbsGravity = GravityCompat.getAbsoluteGravity(mCollapsedTextGravity,
            mIsRtl ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR);
    switch (collapsedAbsGravity & Gravity.VERTICAL_GRAVITY_MASK) {
    case Gravity.BOTTOM:
        mCollapsedDrawY = mCollapsedBounds.bottom;
        break;/*from  ww  w.  j  av  a  2s. c  om*/
    case Gravity.TOP:
        mCollapsedDrawY = mCollapsedBounds.top - mTextPaint.ascent();
        break;
    case Gravity.CENTER_VERTICAL:
    default:
        float textHeight = mTextPaint.descent() - mTextPaint.ascent();
        float textOffset = (textHeight / 2) - mTextPaint.descent();
        mCollapsedDrawY = mCollapsedBounds.centerY() + textOffset;
        break;
    }
    switch (collapsedAbsGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
    case Gravity.CENTER_HORIZONTAL:
        mCollapsedDrawX = mCollapsedBounds.centerX() - (width / 2);
        break;
    case Gravity.RIGHT:
        mCollapsedDrawX = mCollapsedBounds.right - width;
        break;
    case Gravity.LEFT:
    default:
        mCollapsedDrawX = mCollapsedBounds.left;
        break;
    }

    mTextPaint.setTextSize(mExpandedTextSize);
    width = mTextToDraw != null ? mTextPaint.measureText(mTextToDraw, 0, mTextToDraw.length()) : 0;
    final int expandedAbsGravity = GravityCompat.getAbsoluteGravity(mExpandedTextGravity,
            mIsRtl ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR);
    switch (expandedAbsGravity & Gravity.VERTICAL_GRAVITY_MASK) {
    case Gravity.BOTTOM:
        mExpandedDrawY = mExpandedBounds.bottom;
        break;
    case Gravity.TOP:
        mExpandedDrawY = mExpandedBounds.top - mTextPaint.ascent();
        break;
    case Gravity.CENTER_VERTICAL:
    default:
        float textHeight = mTextPaint.descent() - mTextPaint.ascent();
        float textOffset = (textHeight / 2) - mTextPaint.descent();
        mExpandedDrawY = mExpandedBounds.centerY() + textOffset;
        break;
    }
    switch (expandedAbsGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
    case Gravity.CENTER_HORIZONTAL:
        mExpandedDrawX = mExpandedBounds.centerX() - (width / 2);
        break;
    case Gravity.RIGHT:
        mExpandedDrawX = mExpandedBounds.right - width;
        break;
    case Gravity.LEFT:
    default:
        mExpandedDrawX = mExpandedBounds.left;
        break;
    }

    // The bounds have changed so we need to clear the texture
    clearTexture();
}

From source file:com.yktx.check.widget.OldPagerSlidingTabStrip.java

private void addIconAndTextTab(final int position, int resId, String title) {
    LinearLayout layout = new LinearLayout(getContext());
    layout.setGravity(Gravity.CENTER);//from ww w  . java  2  s. c  o  m
    layout.setOrientation(LinearLayout.VERTICAL);
    ImageView tabImage = new ImageView(getContext());
    tabImage.setImageResource(resId);
    tabImage.setId(R.id.image);
    TextView tabText = new TextView(getContext());
    tabText.setText(title);
    tabText.setSingleLine();
    tabText.setId(R.id.text);
    tabText.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    tabText.setGravity(Gravity.CENTER_HORIZONTAL);
    tabText.setPadding(0, 3, 0, 0);
    layout.addView(tabImage);
    layout.addView(tabText);

    addTab(position, layout);

}

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  ww  . 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);
}