当计时器开始打勾时,'文字'有时会移动..你认为是什么原因?我将计时器放在一个相对布局中,匹配父填充..
我错过了其他任何设置吗?我还设置了重力:天文台的中心
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_alignParentRight="true"
android:layout_below="@+id/textView1"
android:layout_marginBottom="10dp" >
<Chronometer
android:id="@+id/stopwatch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:gravity="center_horizontal"
android:text="Chronometer"
android:textSize="110dp" />
</RelativeLayout>
答案 0 :(得分:0)
您的android:gravity="center_horizontal"
是问题所在。每次文本从增量刻度变化时,它都会重新对齐水平居中的文本。如果您在计时器中移除了中心对齐,那么您将不会遇到问题,因为它应该默认为左对齐。
您可能必须使用边距将天文台放置在您需要的位置而不是布局内。例如:
<Chronometer
android:id="@+id/stopwatch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:text="Chronometer"
android:textSize="110dp" />
答案 1 :(得分:-1)
试试这个
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/textView1"
android:layout_marginBottom="10dp" >
<Chronometer
android:id="@+id/stopwatch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:gravity="center_horizontal"
android:text="Chronometer"
android:textSize="110sp" />
</RelativeLayout>