Android Open Source - app-gkplayer-android Vertical Text View






From Project

Back to project page app-gkplayer-android.

License

The source code is released under:

Apache License

If you think the Android project app-gkplayer-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.roamtouch.gesturekit.gkplayer.graphics;
//from w  w w  .  j  ava  2  s  .  c o  m
import android.content.Context;
import android.graphics.Canvas;
import android.text.TextPaint;

import android.view.Gravity;
import android.widget.TextView;

public class VerticalTextView extends TextView{
  final boolean topDown;

  public VerticalTextView(Context context){
    super(context);
    final int gravity = getGravity();
    if(Gravity.isVertical(gravity) && (gravity&Gravity.VERTICAL_GRAVITY_MASK) == Gravity.BOTTOM) {
      setGravity((gravity&Gravity.HORIZONTAL_GRAVITY_MASK) | Gravity.TOP);
      topDown = false;
    }else
      topDown = true;
  }

  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec){
    super.onMeasure(heightMeasureSpec, widthMeasureSpec);
    setMeasuredDimension(getMeasuredHeight(), getMeasuredWidth());
  }

  @Override
  protected void onDraw(Canvas canvas){
    TextPaint textPaint = getPaint(); 
    textPaint.setColor(getCurrentTextColor());
    textPaint.drawableState = getDrawableState();

    canvas.save();

    if(topDown){
      canvas.translate(getWidth(), 0);
      canvas.rotate(90);
    }else {
      canvas.translate(0, getHeight());
      canvas.rotate(-90);
    }


    canvas.translate(getCompoundPaddingLeft(), getExtendedPaddingTop());

    getLayout().draw(canvas);
    canvas.restore();
  }
}




Java Source Code List

com.roamtouch.gesturekit.gkplayer.GKPlayer.java
com.roamtouch.gesturekit.gkplayer.PlayerLayout.java
com.roamtouch.gesturekit.gkplayer.graphics.Blur.java
com.roamtouch.gesturekit.gkplayer.graphics.ProgressView.java
com.roamtouch.gesturekit.gkplayer.graphics.Utils.java
com.roamtouch.gesturekit.gkplayer.graphics.VerticalTextView.java
com.roamtouch.gesturekit.gkplayer.graphics.VolumeControl.java
com.roamtouch.gesturekit.gkplayer.service.AudioFocusHelper.java
com.roamtouch.gesturekit.gkplayer.service.AudioFocus.java
com.roamtouch.gesturekit.gkplayer.service.ContentListener.java
com.roamtouch.gesturekit.gkplayer.service.MusicBinder.java
com.roamtouch.gesturekit.gkplayer.service.MusicFocusable.java
com.roamtouch.gesturekit.gkplayer.service.MusicIntentReceiver.java
com.roamtouch.gesturekit.gkplayer.service.MusicRetriever.java
com.roamtouch.gesturekit.gkplayer.service.MusicService.java
com.roamtouch.gesturekit.gkplayer.service.PrepareMusicRetrieverTask.java
com.roamtouch.gesturekit.gkplayer.service.Song.java
com.roamtouch.gesturekit.gkplayer.service.State.java