How to make a Shape figure in the shape of the right circle when displayed on all screens



  • I'm gonna make round blocks in the menu, but different devices look different. The question is, how do we do anything on all the devices they were perfectly round?

    Code:

    <?xml version="1.0" encoding="UTF-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android">
      <solid android:color="#ffffffff"/>
       <solid android:color="#4CAF50" >
       </solid>
      <corners android:radius="30dp"/>
    </shape>
    

    введите сюда описание изображения



  • UPD To create a view with a background in the shape of the right circle, a picture (click here) res/drawable/rating.png(d) and subscription at the bottom, at random, using such design:

    res/drawable/image_in_circle.xml

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
        <item>
            <shape android:shape="oval">
                <solid android:color="#4CAF50"/>
            </shape>
        </item>
    
    &lt;item android:drawable="@drawable/rating"
          android:bottom="5dp"
          android:left="5dp"
          android:right="5dp"
          android:top="5dp"/&gt;
    

    </layer-list>

    The size of the circle will be approached to the size of the 5dp derogated

    Use:

    <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/textView"
    android:drawableTop="@drawable/image_in_circle"
    android:text="камера"
    android:gravity="center_horizontal">

    The results on all screens are the same:
    screen

    It'll also be inconvenient to indicate what kind of figure you draw.android:shape="oval"because Shape It draws a rectangle and arc et al.

    PS: In your marking, the color indicated by the first (#FFFFFF) does not affect anything.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2