【发布时间】:2010-07-28 17:11:18
【问题描述】:
我正在使用 textview 对象在我的游戏屏幕上保存诸如分数、级别等标签,但它们似乎没有显示在我想要的位置。我了解视图层次结构(父母、孩子)并且在 XML 布局文件中使用重力标签,但它似乎没有任何效果。
是否有人可以快速提供在屏幕上定位 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>
【问题讨论】: