我想在我的Android布局中使用文本视图,文本应该向左旋转90度。文本视图的宽度相当小(20dp)。我的代码如下所示:
<TextView
android:id="@+id/txtVw"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:minWidth="20dp"
android:maxWidth="20dp"
android:paddingEnd="6dp"
android:rotation="270"
android:text="Test"/>
旋转已完成,但只显示那些在没有旋转的情况下可见的字符-但有足够的空间来显示所有字符。有谁有主意吗?
发布于 2019-06-05 03:24:46
我认为这真的是一个bug,但我自己找到了一个没有自定义TextView的解决方案-如果其他人需要解决这个问题的解决方案,我会发布它:
<TextView
android:id="@+id/txtVwOne"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:height="20dp"
android:gravity="end"
android:maxWidth="40dp"
android:minWidth="40dp"
android:rotation="270"
android:text="Test" />
<TextView
android:id="@+id/txtVwTwo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="fill"
android:layout_weight="1"
android:layout_marginLeft="-20dp"
android:minHeight="40dp" />
诀窍是将最小宽度和最大宽度设置为一个值,该值将允许文本不以水平对齐方式剪切。布局高度必须设置为所需的高度。高度属性必须设置为文本视图的目标宽度。以下文本视图必须包含android:layout_marginLeft="-20dp"
,以确保将其向左移动20dp(目标位置)。
https://stackoverflow.com/questions/56440317
复制相似问题