2010-07-28 5 views
0

내 게임 화면에 점수, 레벨 등의 레이블을 붙이기 위해 textview 객체를 사용하고 있지만 원하는 위치에 표시되지 않는 것 같습니다. 뷰 계층 구조 (부모, 자식)에 대해 이해하고 XML 레이아웃 파일에서 중력 태그를 사용하고 있지만 효과가없는 것 같습니다.도움말 Android의 화면에 TextView 객체 정렬

누군가가 방금 화면에 텍스트 뷰를 배치하는 방법에 대한 가이드를 제공하고 해당 내용을 프로그래밍 방식으로 제어 할 수 있도록 코드에 링크 할 수도 있습니까 (이 방법은 = (TextView) findViewById (r .id.resourcename))?

많은 감사

XML :

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
> 

    <android.gesture.GestureOverlayView 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/gestures" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:gestureStrokeWidth="2.0" 


android:gestureStrokeType="multiple" 
android:eventsInterceptionEnabled="true"> 


<com.darius.android.distractions.DistractionsView 
    android:id="@+id/distractions_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"/> 




<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 
    <TextView 
     android:id="@+id/text" 
       android:text="Hello" 
       android:visibility="visible" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" 
     android:gravity="center_horizontal" 
     android:textColor="#88ffffff" 
     android:textSize="24sp"/> 

     <TextView 
     android:id="@+id/textLevel" 
       android:text="@string/level_count" 
       android:visibility="visible" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" 
     android:gravity="bottom" 
     android:textColor="#EB0000" 
     android:textSize="10sp"/> 


<TextView android:layout_height="wrap_content" 
      android:layout_width="wrap_content" 
      android:text="@string/concentration_bar" 
      android:textColor = "#EB0000" 
      android:textSize="10sp" 
      android:id="@+id/conbartext" 
      android:visibility="visible"    

      ></TextView> 

</RelativeLayout> 

</android.gesture.GestureOverlayView> 
    </FrameLayout> 

답변

0

Common Layout Objects이 레이아웃의 기초에 좋은 가이드입니다. 중력 태그는 특정 레이아웃 유형에서만 의미가 있습니다.

다른 유용한 도구는 Android 설치 도구 폴더에있는 계층 뷰어입니다. 이를 통해 실행중인 활동의 계층 구조를 시각화 할 수 있습니다.

레이아웃 XML을 게시하고 성취하고자하는 것에 대한 모형을 작성하면이를 수행하는 데 도움을 줄 수 있습니다. http://developer.android.com/resources/tutorials/views/index.html

문서 및 레이아웃 자체에 대한 가이드 여기에 있습니다 : :

+0

내 XML을 추가했습니다. 가로 지향 화면에서 정수 스코어 변수에 연결된 화면의 오른쪽 하단에 스코어 텍스트 뷰 레이블을 붙이고 싶습니다. 예를 들어 "점수 : 1000"이 표시됩니다. 그리고 아마도 그것의 왼쪽에는 "Level : 3"과 비슷한 텍스트 뷰 객체가 있습니다. 시간과 도움을 많이 주셔서 감사합니다. – ComethTheNerd