2015-08-14 4 views
12

में कोलन लंबवत केंद्र कैसे बना सकता हूं मेरे पास TextView समय दिखा रहा है। समय हर सेकेंड अद्यतन करता है।मैं टेक्स्टव्यू

मैंने डीआईएन फ़ॉन्ट का उपयोग किया। मैंने TextView को केंद्र संरेखण (लंबवत) पर सेट किया है। कोलन आधार रेखा से संरेखित क्यों करता है? कौन जानता है कि इस मुद्दे को कैसे ठीक किया जाए?

enter image description here


अद्यतन

   <TextView 
        android:id="@+id/time" 
        android:layout_width="wrap_content" 
        android:layout_height="48px" 
        android:layout_below="@id/temperature" 
        android:layout_centerHorizontal="true" 
        android:layout_marginBottom="-5px" 
        android:fontFamily="DIN" 
        android:gravity="center" 
        android:textColor="@color/white" 
        android:textSize="39px" /> 
+1

आपके एक्सएमएल पर निर्भर करता है। इसे पोस्ट करें – Nabin

+1

इसे जांचने का प्रयास करें: http://stackoverflow.com/questions/22826411/how-do-i-align-text-view-to-be-in-center-vertically-of-two-numberpickers –

+1

यदि वह यह है कि फ़ॉन्ट ':' ग्लिफ को कैसे प्रस्तुत करता है, तो आप इसे कई दृश्यों में अलग किए बिना बहुत कुछ नहीं कर सकते हैं। – Karakuri

उत्तर

3

डिफ़ॉल्ट तरीका कैसे फ़ॉन्ट पेट के चरित्र बना देता है। जब तक आप कोलन के लिए अलग-अलग टेक्स्ट व्यू नहीं बनाते, तब तक आप इसे बदल नहीं सकते हैं। वैकल्पिक रूप से आप एक अलग फ़ॉन्ट का उपयोग कर सकते हैं और जांच सकते हैं कि किसी अन्य फोंट वास्तव में कोलन chararacter केंद्रित करता है या नहीं। यह करने के लिए निम्नलिखित का उपयोग करें: फोंट जो इस्तेमाल किया जा सकता का एक बेहतर विवरण के लिए

android:fontFamily="sans-serif"   // roboto regular 
android:fontFamily="sans-serif-light"  // roboto light 
android:fontFamily="sans-serif-condensed" // roboto condensed 
android:fontFamily="sans-serif-thin"  // roboto thin (android 4.2) 
android:fontFamily="sans-serif-medium" // roboto medium (android 5.0) 

, आप official documentation जाँच कर सकते हैं।

आशा इस मदद करता है :)

3

एक विकल्प 5 अलग TextViews में पूरी TextView विभाजित और संख्या के साथ लोगों पर android:layout_marginTop="3px" जोड़ने के लिए किया जाएगा।

2

क्योंकि कोलन इतना आसान आकार है क्योंकि आप इसे लंबवत रैखिक लेआउट में छोटे तत्वों, या तो पाठ दृश्य, ग्राफिक प्राइमेटिव, या केवल दो विचारों से बना सकते हैं।

उदाहरण के लिए, (drawable फ़ोल्डर में dot.xml) एक आकार drawable के रूप में बस एक बिंदु बना कर शुरूआत:

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
     android:shape="oval"> 
    <solid android:color="#ccc"/> 
</shape> 

पृष्ठभूमि (लेआउट में clock_dot.xml के रूप में इस drawable के साथ एक दृश्य बनाएँ फ़ोल्डर):

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:orientation="vertical" 
      android:layout_gravity="center_vertical" 
      android:gravity="center_vertical" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent"> 
    <include layout="@layout/clock_dot"/> 
    <include layout="@layout/clock_dot"/> 
</LinearLayout> 
:

<?xml version="1.0" encoding="utf-8"?> 
<View xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="3sp" 
    android:layout_height="3sp" 
    android:background="@drawable/dot" 
    android:layout_margin="3sp" 
    android:layout_weight="0" /> 

ढेर दो डॉट्स पेट के चरित्र (लेआउट फ़ोल्डर में clock_colon.xml) बनाने के लिए

दो अंक (clock_digits.xml) के साथ एक पाठ दृश्य बनाएँ:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:orientation="horizontal" 
      android:gravity="center_vertical" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"> 
    <include layout="@layout/clock_digits"/> 
    <include layout="@layout/clock_colon"/> 
    <include layout="@layout/clock_digits"/> 
    <include layout="@layout/clock_colon"/> 
    <include layout="@layout/clock_digits"/> 
</LinearLayout> 

आप कुछ इस तरह मिलती है::

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_weight="0" 
    android:textColor="#ccc" 
    android:textSize="24sp" 
    android:text="12" /> 

फिर अंक लेआउट और पेट के लेआउट से एक टाइमर लेआउट बनाने

Screen shot of timer

+0

अंततः मैं एक और फ़ॉन्ट का उपयोग करता हूं। लेकिन बहुत बहुत धन्यवाद। आप भी आदर्श सहायक हैं। – smallTong

संबंधित मुद्दे