【问题标题】:How to change the position of the hands of an analog clock for Android?如何更改 Android 模拟时钟指针的位置?
【发布时间】:2013-06-28 15:44:58
【问题描述】:

我正在使用本教程制作模拟时钟: Make your own analog clock

我想使用的布局有点不同。我想制作一个 4x2 模拟时钟,左边是实际时钟,右边是一个带有一些文字的小条。我遇到的问题是时钟的指针停留在图像的中间,而不是在左侧。我的 XML 中的代码如下所示:

<?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

        <AnalogClock
            android:id="@+id/analogClock4x2countdown"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:dial="@drawable/hand_dial_4x2countdown"
            android:hand_hour="@drawable/hand_hour"
            android:hand_minute="@drawable/hand_minute" />

    </RelativeLayout>

An example of what it looks like visually。这也说明了问题所在。

我的问题是:我如何定位时钟的指针以使其处于正确的位置?

【问题讨论】:

  • 请完成该教程,如果您仍有问题,请返回。
  • 我已经完成了上面提到的教程并且最终的结果工作正常。问题是我似乎无法将时钟的指针放在正确的位置,如我发布的图片所示。
  • 我最终使用的解决方案是使时钟的表盘透明并在其后面放置图像。然后我用透明表盘移动时钟,使其正确对齐。

标签: android android-layout android-widget


【解决方案1】:

您可以通过仅在 xml 上的图形布局上拖动小部件来更改时钟的位置和大小,但在相对布局中,根据您的意愿拖动可能无法选择一种绝对布局作为 maun 布局

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-16
    • 2019-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-22
    • 1970-01-01
    • 2013-05-20
    相关资源
    最近更新 更多