상대 레이아웃을 사용 중이며 첨부 된 이미지와 같이 아래쪽과 가운데에있는 TextView를 정렬하려고합니다. 나는 아래쪽을 사용하여 아래에 그것을 얻을 수 있지만 그들의 수평 중심을 정렬하는 방법을 알아낼 수 없습니다.상대 레이아웃 아래 항목을 다른 항목의 가운데에 맞 춥니 다
4
A
답변
6
가장 쉬운 방법은
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/imageView1"
android:layout_centerHorizontal="true"
android:text="TextView" />
</RelativeLayout>
편집
하나의 레이아웃에서이 작업을 수행하려면 당신의 텍스트 뷰에 android:drawableTop
을 추가 할 상대 레이아웃에 이미지와 텍스트 뷰를 배치하는 것입니다
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:drawableTop="@drawable/ic_launcher"/>
+0
을 center_horizontal에 비해 레이아웃의 무게를 설정하지만 ANO 만들지 않고 그것을 할 기대했다 상대적인 레이아웃. – RunLoop
+0
동일한 레이아웃에서 작업하려면 DrawableTop with TextView를 사용하십시오. –
0
간단한 방법을 수행하는 :
- 설정 "match_parent"에 layout_width 속성의
- 의 폭이 그런 다음 "중력"을 "center_horizontal"를
속성을 설정이 방법 예 :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:gravity="center_horizontal"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:src="@drawable/ic_launcher" />
<TextView
android:layout_below="@+id/imageView1"
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView"
android:gravity="center_horizontal" />
</RelativeLayout>
관련 문제
- 1. 가운데에 글리프콘을 가운데에 맞 춥니 다.
- 2. 노드를 세로로 가운데에 맞 춥니 다. ASStackLayout
- 3. DataGridView에서 현재 레코드를 가운데에 맞 춥니 다
- 4. SVG 셰이프를 서로 가운데에 맞 춥니 다
- 5. 가변 폭 div를 가운데에 맞 춥니 다
- 6. 문서에서 div를 가운데에 맞 춥니 다.
- 7. 웹보기 내용을 이동하거나 가운데에 맞 춥니 다
- 8. 이미지를 텍스트로 가운데에 맞 춥니 다.
- 9. 쉽게 Xul에서 레이블을 가운데에 맞 춥니 다
- 10. 마우스 커서를 화면 가운데에 맞 춥니 다
- 11. Google지도를 동적으로 가운데에 맞 춥니 다.
- 12. 어떻게 CSS로 텍스트를 가운데에 맞 춥니 다
- 13. UISegmentControl에서 이미지를 가운데에 맞 춥니 다?
- 14. Activityindicator를 Xamarin.Forms의 가운데에 맞 춥니 다
- 15. JTable의 셀을 JTable의 가운데에 맞 춥니 다
- 16. UIImageView를 UIScrollView의 가운데에 맞 춥니 다
- 17. 컨테이너에서 요소를 가로로 가운데에 맞 춥니 다.
- 18. div를 페이지 가운데에 맞 춥니 다
- 19. 하나의 축소판 그림을 다른 줄 가운데에 맞 춥니 다
- 20. 스크롤하면서 다른 div의 div를 가운데에 맞 춥니 다
- 21. 양 옆의 텍스트 가운데에 텍스트를 가운데에 맞 춥니 다. (왼쪽 및 아래) CSS 전용
- 22. 부모보기 내에서 UIView를 가로 및 세로 가운데에 맞 춥니 다
- 23. NSTableView 내부에 NSButton 위치를 프로그래밍 방식으로 가운데에 맞 춥니 다
- 24. QGridLayout의 여러 열을 중심으로 단추 가운데에 맞 춥니 다
- 25. div 내에서 4 개의 div를 가운데에 맞 춥니 다
- 26. iOS 자동 레이아웃 : 한 버튼의 가장자리를 다른 버튼의 가운데에 맞 춥니 다?
- 27. 오버플로가있는 div를 수직 및 수평으로 가운데에 맞 춥니 다.
- 28. html div 위의 공백을 제거하고 가운데에 맞 춥니 다.
- 29. 내용이 화면보다 넓은 경우에도 div를 가운데에 맞 춥니 다
- 30. 텍스트를 세로 및 가로로 가운데에 맞 춥니 다
상대 레이아웃에서이 두 가지를 넣고이 좋아 보인다 –