2014-09-06 66 views
0

我在運行時有一個textview,我在120度旋轉它,使用mytextview.setRotation(120);根據運行時需求Android的高度變化寬度

做的就是它切割我的文字(無法看到外面查看文本)

我的佈局是

<RelativeLayout 
    android:layout_width="wrap_content" 
    android:id="@+id/rel" 
    android:background="@android:color/darker_gray" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:padding="20dp" > 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 

     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:longClickable="true" 
     android:text="TextView" 
     android:typeface="monospace" /> 
</RelativeLayout> 

我應該怎麼做的問題?旋轉角度是動態的並且根據用戶而改變。如何克服這個問題?

其實我可以旋轉視圖,但我的textview不顯示整個字符串。即如果字符串是Hello,那麼在旋轉之後它只顯示Hel,之後不顯示這些字。

回答

0

的這兩個選項之一可以幫助您:

android:adjustviewbounds="true" 
在運行時

programmaticly:旋轉後,您可以設置widht和高度有:

view. getlayoutparams().widht = ... 
view. getlayoutparams().height = ... 
+0

使用視圖。 getlayoutparams()。widht = ... view。 getlayoutparams()。height = ..它會固定大小,但我需要它根據動態不同的屏幕和不同的字符串長度 – Android 2014-09-06 08:18:10

+1

然後編寫一個方法,根據您的源參數(屏幕,字符串)動態設置您的佈局參數。在我看來,沒有官方的Android解決方案。你可以看看這個項目https://github.com/rongi/rotate-layout – Izu 2014-09-07 07:56:58

相關問題