[英]how to rotate textView in LinearLayout?
我想在項目中的linearlayout內旋轉textView。 但是只有textView的一部分在旋轉時被淹死。
這是我的xml。
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/Test"
android:layout_below="@+id/Test"
android:layout_marginTop="34dp"
android:orientation="vertical"
>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:rotation="90"
android:text="TextView" />
</LinearLayout>
TextView
尺寸 我們應該找到包含中顯示的文本的寬度View
,同時考慮到Font
,並設置heigh
的的View
到這一點。
protected void myMethod() {
//...
//Get component components paint and text
TextView textView = (TextView) findViewById(R.id.textView1);
String text = (String) textView.getText();
Paint paint = textView.getPaint();
//Calculate width of the string given the paint
int width = (int) paint.measureText(text);
//Set the minimum width of the component to the width of text contained
textView.setMinimumHeight(width);
//...
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.