0

this

Why is this happening? How to fix it? I run app on API 23 and res 2560x1440 On tablet with the same API, everything is ok

<TextView
    android:id="@+id/time_view"
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:layout_marginTop="10dp"
    android:layout_marginLeft="10dp"
    android:layout_marginStart="10dp"
    android:background="@drawable/red_circle"
    android:lineSpacingMultiplier="0.7"
    android:textColor="@color/white"
    android:textSize="@dimen/text_size_circle_list_view"
    android:lines="2"
    android:textStyle="bold"

    android:layout_centerVertical="true"
    android:orientation="vertical"
    android:layout_alignParentTop="true"
    android:textAlignment="center"
    android:text="00\n00"
    android:gravity="center" />
CerebralFart
  • 3,336
  • 5
  • 26
  • 29
gzaripov
  • 48
  • 1
  • 7
  • Did you randomly fill all the attributes that came to your mind? many attributes like orientation dont evem work on text view – Mohammed Atif Oct 28 '16 at 18:43
  • `android:lineSpacingMultiplier="0.7"` - Why do you need that? Try without it to see if it helps. – milosmns Oct 28 '16 at 19:22
  • @MohammedAtif almost) I tryied so much things and all gave me wrong result( – gzaripov Oct 28 '16 at 19:35
  • @milosmns thx so much, this solve my problem. I need that to decrease spacing between lines and then i can make the text larger and it fits in the circle – gzaripov Oct 28 '16 at 19:46
  • Cool, I'll post it as an answer then :) But don't add random attributes if you don't need them. – milosmns Oct 28 '16 at 19:48

3 Answers3

2

My opinon use circletextview. easy to use and flexible for all the devices. see the link CircleTextView

See the below code.

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

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/num_txt"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:layout_marginTop="0dp"
            android:background="@drawable/bg_red"
            android:gravity="center"
            android:text="My name is NON"
            android:textColor="#FFFFFF"
            android:textSize="10dp" />

    </RelativeLayout>

</RelativeLayout>

Save in drawable bg_red.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="oval">
    <corners android:radius="10dip"/>
    <stroke android:color="#FF0000" android:width="5dip"/>
    <solid android:color="#FF0000"/>
</shape>

Edited Code

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="match_parent" >
     <TextView
         android:id="@+id/num_txt"
         android:layout_width="185dp"
         android:layout_height="185dp"

         android:layout_alignParentTop="true"
         android:layout_marginTop="163dp"
         android:background="@drawable/bg_red"
         android:gravity="center"
         android:text="My name is NON"
         android:textColor="#FFFFFF"
         android:layout_marginLeft="10dp"
         android:textSize="10dp" />

     <TextView
         android:id="@+id/TextView02"
         android:layout_width="90dp"
         android:layout_height="90dp"
         android:layout_alignParentRight="true"
         android:layout_alignTop="@+id/TextView01"
         android:layout_marginRight="90dp"
         android:layout_marginTop="122dp"
         android:background="@drawable/bg_red"
         android:gravity="center"
         android:text="My name is NON"
         android:textColor="#FFFFFF"
         android:textSize="10dp" />

     <TextView
         android:id="@+id/TextView01"
         android:layout_width="120dp"
         android:layout_height="120dp"
         android:layout_alignTop="@+id/num_txt"
         android:layout_toRightOf="@+id/num_txt"
         android:background="@drawable/bg_red"
         android:gravity="center"
         android:text="My name is NON"
         android:textColor="#FFFFFF"
         android:textSize="10dp" />

</RelativeLayout>
Community
  • 1
  • 1
Magesh Pandian
  • 8,789
  • 12
  • 45
  • 60
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/14129930) – Milad Faridnia Oct 30 '16 at 08:55
  • thanks for review my answer @MiladFaridnia. Your thought right. but i added stack overflow link only. i think stack overflow link never change. – Magesh Pandian Oct 30 '16 at 14:24
  • Your welcome but I suggest you to add the essential parts of the answer here ;) – Milad Faridnia Oct 30 '16 at 17:32
0

try add android:padding="2dp"

0

It is the android:lineSpacingMultiplier="0.7" attribute spec that knocks it off from the center. Generally, try to remove all attributes that are not absolutely crucial to your View's look.

milosmns
  • 3,595
  • 4
  • 36
  • 48