나는 다음 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 크기를 조정할 경우에만 크기를 조정할 수 있지만 그것을 원하지 않습니다. 이유를 모릅니다.
도움
당신은이 일을 시도 할 수
왜 LinearLayout.LayoutParams 대신 RelativeLayout.LayoutParams를 사용하고 있습니까? – aiqency
내 linearLayout의 parnt가 상대적 레이아웃이기 때문에 – user3240604