(Sorry for my poor question. I have update it now)
How can i make it in XML file? I tried to use following code, but not correct (I used "android:rotation="-90" to do rotation.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:layout_width="141dp"
android:layout_height="200dp"
android:layout_weight="0.41"
android:orientation="vertical" >
<EditText
android:id="@+id/sidebar_title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/shape_card_sidebar"
android:inputType="text"
android:rotation="-90"
android:text="I want to be like this" >
</EditText>
</FrameLayout>
You're going to run into several problems if you try to do it that way. The most obvious issue will be the incorrect measurement. Instead you should create a custom view. Something like this:
public class RotatedTextVew extends TextView {
public RotatedTextView(Context context) {
super(context);
}
public RotatedTextView(Context context, AttributeSet attrs) {
super(context, attrs)
}
public RotatedTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// Switch dimensions
super.onMeasure(heightMeasureSpec, widthMeasureSpec);
}
@Override
protected void onDraw(Canvas canvas) {
canvas.save();
canvas.rotate(90);
super.onDraw(canvas);
canvas.restore();
}
}
I haven't actually tested this, but this is how I'd start.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With