Setting an image view's weight and parameters

enlytn

New Member
I am trying to create a layout dynamically and I am having a small issue. For some reason I just cant figure out how to set the ImageViews weight. I looked up this on a tutorial site but when I try to use it I get an error:LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, 1);What I am trying to accomplish is this (From the Outline perspective):--LinearLayout (Horizontal) (LL1)------ImageView (IV1)------LinearLayout(Vertical) (LL2)Code that I am trying to accomplish in XML:\[code\] <LinearLayout android:id="@+id/skillOneAbility" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <ImageView android:id="@+id/skillOneImage" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1"/> <LinearLayout android:id="@+id/skillOneAbilityInfo" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="5" android:orientation="vertical" >\[/code\]This is the code I have so far but I am not sure how to set the weight of the ImageView:\[code\] private LinearLayout createInnerHorizontalLayout1() { LinearLayout mainLayout = new LinearLayout(getActivity()); mainLayout.setOrientation(LinearLayout.HORIZONTAL); mainLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); //Create the image view and the linear layout with text views ImageView iView = new ImageView(getActivity()); iView.setLayoutParams(new LayoutParams(0, LayoutParams.WRAP_CONTENT)); LinearLayout myInnerVerticalLayout = createInnerVerticalLayout();}\[/code\]How would I accomplish that XML that I linked up top?
 
Back
Top