Reputation: 3572
I have a Textview
on which I am trying to add rounded corners on.
My TextView
:
<TextView
android:id="@+id/textview_answer_one"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:background="@drawable/rounded_corners"
android:elevation="4dp"
android:gravity="center"
android:text=""
app:layout_constraintBottom_toTopOf="@+id/guideline5"
app:layout_constraintEnd_toStartOf="@+id/guideline4"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline" />
and my Drawable
file:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<corners android:radius="15dp" />
<solid android:color="#ffffff"/>
</shape>
</item>
</layer-list>
When I check in the XML Editor (I don't know what it's called) in Android Studio, you can clearly see that the TextView have rounded corners. However, when I run the app on my phone the TextView does not have rounded corners. How come? Any suggestions on what I might be doing wrong?
Upvotes: 0
Views: 83
Reputation: 1957
Try This Shape :
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="20dp"/>
<padding android:left="10dp" android:right="10dp" android:top="10dp" android:bottom="10dp"/>
<solid android:color="#CCCCCC"/>
</shape>
Example Xml :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
<TextView
android:background="@drawable/r"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text View"
android:textSize="20dp"
android:textColor="#FFFFFF"
android:gravity="center_horizontal"
/>
</LinearLayout>
Upvotes: 1