2012-08-03 2 views
1

텍스트보기를 centerd Android 버튼보다 약간 위에 배치 할 수 있습니까? 분명히 특정 화면의 값을 하드 코딩하고 싶지는 않지만 동적으로 확장 할 수있는 것이 있습니다. 그러나 버튼은 항상 가운데에 배치됩니다 ...Android 용 텍스트 뷰 위치 지정

미리 감사드립니다!

답변

1

네 부모 레이아웃은 서로 또는 여기에 부모 관련하여 뷰를 배치 할 수있는 RelativeLayout은 (경고 IDE에이를 입력하지 않은, 오타를 포함 할 수 있습니다) 간단한 예입니다 경우 :

<RelativeLayout 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 

<Button 
android:id="@+id/mBtn" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="I am a Button!" 
android:layout_centerInParent="true" /> 

<TextView 
android:id="@+id/mTxt" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_centerHorizontal="true" 
android:text"Some Text" 
android:layout_above="@+id/mBtn" /> 

</RelativeLayout> 
레이아웃을 만들 것입니다

은 다음과 같이 대략 모양 :

________________________ 
|      | 
|      | 
|  Some Text  | 
| [I am a Button!] | 
|      | 
|      | 
|______________________| 
+0

완벽. 정말 고맙습니다! – Mobie