3

I am new to android programming. I am trying to create a basic clock app. I have found the textClock function and have been trying to implement it such that the clock digits stretch to the width of the screen or parent view. Right now when I put in a text clock and define a textSize, the clock looks huge on a nexus 4 and small on a nexus 10.

How to I make the clock stretch to the screen width?

Any help is appreciated. If you provide code, please explain it in detail. Thank you in advance!

cndjonno
  • 76
  • 1
  • 6

3 Answers3

0

you can do this by changing font size dynamically.

you should create a custom widget for it.

here is a very helpful link that shows you how to do this!


TextClock is a widget that extends TextView. you should create your own TextClock for your purpose. in above link, there is sample code for a custom widget that you want.

Community
  • 1
  • 1
Mohammad Rahchamani
  • 5,002
  • 1
  • 26
  • 36
  • I am confused a bit by the link. I am not creating a Widget. I am trying to create an application that is a clock app. Based on that link, it will autosize textView but not the textClock. – cndjonno Jun 19 '15 at 01:12
0

Try to some thing like below
<TextClock android:id="@+id/textClock" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:textSize="40dp" android:layout_marginTop="5dp"/>

Mahbub
  • 93
  • 1
  • 6
0

Can you provide us some code? I can think of several reasons: the layout width, "dp" or "sp" missing after the number... Code will be helpful

YosefBro
  • 596
  • 1
  • 7
  • 17