如何将旋转的TextView对齐到RelativeLayout的左侧

问题描述 投票:0回答:1

我已将TextView旋转了270度。但是问题在于它是从x轴的中点旋转的,因此在左右两侧都有一个空间。并且由于空间原因,文本无法在“相对”布局的左侧对齐。

这是我的代码

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="vertical"
     android:layout_width="match_parent"
     android:layout_height="300dp">
     <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:rotation="270"
        android:text="Sept 2015 - Dec 2016"
      />
</RelativeLayout>

这里是结果。

enter image description here

我想这样对齐TextView

enter image description here

android textview
1个回答
0
投票

View类具有setPivotX()和setPivotY()方法,它们设置围绕其旋转的点。使用这些方法设置方便的旋转点。对应的属性是android:transformPivotX和android:transformPivotY

© www.soinside.com 2019 - 2024. All rights reserved.