首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Jelly Bean数字时钟

Jelly Bean数字时钟
EN

Stack Overflow用户
提问于 2013-03-09 08:15:42
回答 1查看 798关注 0票数 0

我想做一个像Jelly bean一样的时钟(小时以粗体显示,分钟正常),如下图所示:

我从安卓openSource下载了EditClock小工具,时钟可以工作了,但我不能让“大胆”的工作im使用以下代码:EditClock Source Code im使用果冻豆字体。这是我布局的一部分

代码语言:javascript
复制
<com.myApp.views.DigitalClock
        android:id="@+id/digitalClock1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/musicDashboard"
        android:layout_centerHorizontal="true" >
        
         <TextView android:id="@+id/timeDisplayBackground"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:singleLine="true"
            android:textColor="#ffffffff"
            android:textSize="@dimen/clock_text_size"
           
            android:textAppearance="?android:attr/textAppearanceMedium"
           android:layout_marginBottom="6dip"
            android:ellipsize="none"
            />

        <TextView android:id="@+id/timeDisplayForeground"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:singleLine="true"
            android:ellipsize="none"
             android:textStyle="bold"
            android:textColor="#ffffffff"
            android:layout_alignStart="@+id/timeDisplayBackground"
             android:textAppearance="?android:attr/textAppearanceMedium"
            android:layout_alignTop="@+id/timeDisplayBackground"
            android:layout_marginBottom="6dip"
            android:textSize="@dimen/clock_text_size"
            />
    </com.myApp.views.DigitalClock>

我怎么才能让它工作呢?姜饼和更高的?谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-03-09 08:37:25

您可以修改DigitalClock小部件的代码,在文本的第一部分周围添加一个跨度。在updateTime()方法中尝试以下代码:

代码语言:javascript
复制
CharSequence newTime = DateFormat.format(mFormat, mCalendar);
SpannableString spannable = new SpannableString(newTime);
int endIndex = spannable.indexOf(':');
spannable.setSpan(new StylePan(Typeface.BOLD), 0, endIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
mTimeDisplayBackground.setText(spannable);
mTimeDisplayForeground.setText(spannable);
mAmPm.setIsMorning(mCalendar.get(Calendar.AM_PM) == 0);
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15305575

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档