我有下一个xml:
<RelativeLayout>
<ImageView
android:id="@+id/imageView1"
android:src="@drawable/image_back" />
<LinearLayout
android:id="@+id/linearLayoutNames"
android:layout_height = "fill_parent"
android:layout_weight = "fill_parent"
android:layout_alignTop = "@+id/image_back"
android:layout_marginTop = "38dp" />
<LinearLayout
android:id="@+id/linearLayoutPoints
android:layout_height = "wrap_content"
android:layout_weight = "wrap_content"
android:layout_alignBottom = "@+id/image_back"
android:layout_below = "@+id/linearLayoutNames" />
</RelativeLayout>
我的程序代码:
LinearLayout linearLayoutPoints = (LinearLayout) findViewRoot(R.id.linearLayoutPoints);
RelativeLayout.LayoutParams layoutParams = (android.widget.RelativeLayout.LayoutParams) linearLayoutPoints.getLayoutParams();
layoutParams.width = 200;
layoutParams.height = 300;
linearLayoutPoints.setLayoutParams(layoutParams);
我想调整linearLayoutPoints的大小,但是当Y尝试时,没有任何反应!如果我调整de imageView1的大小,只调整它,但我不想这样做。 不知道为什么。
帮助
答案 0 :(得分:0)
您可以尝试这样做:
layoutParms.setMargin(0, 0, 0, (layoutParms.height -200));
这可能有效,因为布局在图像和其他布局之间是紧张的。