Note that there are some explanatory texts on larger screens.

plurals
  1. POandroid vertical textview with image next to it
    text
    copied!<p>ive found a lot of info on how to subclass a textview &amp; display the text vertically.</p> <p>Iam trying to display a star next to the text and iam having problems. maybe you have some ideas on this.</p> <p>Subclass:</p> <pre><code>public class VerticalTextView extends TextView { final boolean topDown; public VerticalTextView( Context context, AttributeSet attrs ) { super( context, attrs ); final int gravity = getGravity(); if ( Gravity.isVertical( gravity ) &amp;&amp; ( gravity &amp; Gravity.VERTICAL_GRAVITY_MASK ) == Gravity.BOTTOM ) { setGravity( ( gravity &amp; 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(); } </code></pre> <p>}</p> <p>and Iam setting the star with this code from my fragment:</p> <pre><code>ItemTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, android.R.drawable.btn_star_big_on, 0); </code></pre> <p>no star is displayed.only blank space. and ideas???</p> <p><strong>the subclass is used in a listview. under a specific condition one item of the listview I want to have a star next to it, so **I think i have to do it by code.</strong></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload