2011-12-05 11 views
2

私はアプリケーションでZxingバーコードスキャナを使用していますが、スキャナビューのテキストを下部ではなく右側に表示したいのですが、スキャナビューは水平ビューに設定されていますが、私はそれを変更したくありません。私はちょうど右に表示されるようにヘルプテキストを含むtextViewを回転させたい。助言がありますか?TextViewを回転する方法

+0

私たちのUIをコピーして貼り付けることから始めないでください。これは強くお勧めします。あなた自身のスキャナアプリを書く必要がありますし、私たちの変更方法を理解する必要はありません。 –

答えて

1

最初にこのコードをこのres/anim/rotate.xmlのようなフォルダを作成し、コードの下に与え、

<rotate xmlns:android="http://schemas.android.com/apk/res/android" 
android:fromDegrees="0" android:toDegrees="360" android:toYScale="0.0" 
android:pivotX="40%" android:pivotY="30%" android:duration="2000" /> 

助けるかもしれないあなたのTextView.あなたを回転させることができますこれを修正することができます。そして、このaritcleも見てください。これは助けあなたのものとすることができる

Rotating TextView Using Animation

希望。

3

カスタムTextViewには、あなた

public class TRotate extends TextView { 

public TRotate(Context context) { 
    super(context); 
    // TODO Auto-generated constructor stub 
} 

@Override 
    protected void onDraw(Canvas canvas) { 
     canvas.save(); 
     canvas.rotate(45, getWidth()/2, getHeight()/2); 
     super.onDraw(canvas); 
     canvas.restore(); 
    } 

}

+0

タンク、それは助けますが、私はこれをXMLにどのように実装しますか?私はこれをした: まだいくつかの例外があります – user992804

+0

このアプローチを使用すると、textviewの境界はどうなりますか? – Niko

2

テキストビューを45度回転したかったのです。だから、ここで私は作業サンプルを掲示しています。

<TextView 
    android:id="@+id/txt_discount_tag" 
    android:layout_width="80dp" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_marginLeft="-20dp" 
    android:layout_marginTop="15dp" 
    android:background="@color/red" 
    android:gravity="center" 
    android:rotation="315" 
    android:text="1% Off" 
    android:textSize="@dimen/px_33" /> 
関連する問題