Android根据运行时的要求更改视图的高度宽度

时间:2014-09-06 07:46:20

标签: android layout textview

我在运行时有一个textview,我使用mytextview.setRotation(120);在120度旋转它。

要解决的问题是剪切我的文字(无法在视图外看到文字)

我的布局是

<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,之后不会显示单词。

1 个答案:

答案 0 :(得分:0)

这两个选项中的一个可以帮助您:

 android:adjustviewbounds="true"

在运行时以编程方式:在旋转之后,您可以使用以下方法设置宽度和高度:

 view. getlayoutparams().widht = ...
 view. getlayoutparams().height = ...
相关问题