我的下一個XML:的LinearLayout變化大小
<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嘗試,什麼都不會發生!只調整它,如果我調整imageView1的大小,但我不想要的。 不知道爲什麼。
幫助
爲什麼使用RelativeLayout.LayoutParams代替LinearLayout.LayoutParams? – aiqency
,因爲我的linearLayout的parnt是相對佈局 – user3240604