2016-10-19 4 views
0

나는 다음 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 크기를 조정할 경우에만 크기를 조정할 수 있지만 그것을 원하지 않습니다. 이유를 모릅니다.

도움

당신은이 일을 시도 할 수
+0

왜 LinearLayout.LayoutParams 대신 RelativeLayout.LayoutParams를 사용하고 있습니까? – aiqency

+1

내 linearLayout의 parnt가 상대적 레이아웃이기 때문에 – user3240604

답변

0

: 당신은 이미지와 antoher 레이아웃 사이에 긴장되어 레이아웃 때문 작동 할 수

layoutParms.setMargin(0, 0, 0, (layoutParms.height -200)); 

.

+0

죄송합니다. 여기 wriong를 작성합니다! 내 실수, 내 질문을 편집합니다 – user3240604

+0

레이아웃의 크기가 변경되지 않는다는 것을 어떻게 알 수 있습니까? 레이아웃에 요소가 없습니다. – Timo

+0

또 다른 해결책은 코드에서 alignBottom 규칙을 제거하는 것입니다. – Timo