调整宽度和宽度在Android中旋转90度后的视图高度

时间:2016-04-25 05:45:56

标签: android view rotation width programmatically-created

我想添加视图&以编程方式将其旋转90度,但我无法确定如何正确设置其尺寸。

这是我的占位符:

var gulost:Object = new Object;
btn.addEventListener(MouseEvent.CLICK, leggTilListe)

function leggTilListe (e:MouseEvent) {
    //...Put your listener code here...
}

这就是我的代码的样子:

        <FrameLayout
            android:layout_width="40dp"
            android:layout_height="match_parent"
            android:id="@+id/placeholder"
            android:orientation="vertical"
            android:background="@color/green"
            android:layout_weight="1">

结果是BOTH宽度和宽度height获取相同的值,因此视图如下所示:

enter image description here

虽然我希望它扩展其父级的整个高度。

1 个答案:

答案 0 :(得分:1)

ViewGroup.LayoutParams.FILL_PARENTHello可以试试这个  而不是这个:

myView.setRotation(90);
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)

试试这个:

删除setRotation

FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
相关问题