Adjusting width & height for view after rotating it by 90 degree in Android -
i want add view & rotate 90 degree programmatically, can't figure how set dimensions properly.
this placeholder:
<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">
and how code looks like:
framelayout placeholderview = (framelayout) findviewbyid(r.id.placeholder); view myview = new view(getapplicationcontext()); myview.setbackgroundcolor(color.red); myview.setrotation(90); framelayout.layoutparams layoutparams = new framelayout.layoutparams(viewgroup.layoutparams.match_parent, viewgroup.layoutparams.match_parent); myview.setlayoutparams(layoutparams); placeholderview.addview(myview);
the result both width & height same value, view looks this:
while wanted expand on entire height of parent.
viewgroup.layoutparams.fill_parenthello can please try instead of this:
myview.setrotation(90); framelayout.layoutparams layoutparams = new framelayout.layoutparams(viewgroup.layoutparams.match_parent, viewgroup.layoutparams.match_parent)
try this:
remove setrotation
framelayout.layoutparams layoutparams = new framelayout.layoutparams(viewgroup.layoutparams.fill_parent, viewgroup.layoutparams.fill_parent);
Comments
Post a Comment