[英]Radius corners of views in xml
I have an Android calculator app that I'm working on and I want to make the text view corners radius and there is two text views I want to appear to be one so I need to only round 2 corners on the outside edge of the views. 我有一个正在使用的Android计算器应用,我想使文本视图的角半径成为半径,并且我希望将两个文本视图显示为一个,因此我只需要在视图的外部边缘上倒圆2个角。 Here is my main.xml
这是我的main.xml
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal" >
<TextView
android:id="@+id/question"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginBottom="3dp"
android:layout_marginLeft="2dp"
android:layout_marginTop="3dp"
android:layout_weight="1"
android:gravity="center|right"
android:padding="5dp"
android:text="0 + 0"
android:textColor="#ff333333"
android:textSize="30sp" />
<TextView
android:id="@+id/answer"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginBottom="3dp"
android:layout_marginRight="2dp"
android:layout_marginTop="3dp"
android:layout_weight="1"
android:gravity="center|left"
android:padding="5dp"
android:text="= ?"
android:textColor="#ff333333"
android:textSize="30sp" />
<Button
android:id="@+id/clear"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="1dp"
android:layout_weight="1"
android:background="@drawable/enter_back"
android:gravity="center"
android:padding="5dp"
android:text="C"
android:textColor="#ff333333"
android:textSize="30sp"
android:textStyle="bold" />
</LinearLayout>
You can do this by adding 3 new android xml files to your drawable folder then setting them as background in your main.xml file. 您可以通过在可绘制文件夹中添加3个新的android xml文件,然后在main.xml文件中将它们设置为背景来实现。 to the right views
正确的看法
android:background="@drawable/answer_back" to the main.xml view @ id="@+id/answer" answer_back.xml to radius the right side corners: android:background =“ @ drawable / answer_back”到main.xml视图@ id =“ @ + id / answer” answer_back.xml半径到右角:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:dither="true" >
<gradient
android:angle="90"
android:endColor="#ffffffff"
android:startColor="#ff99ffcc" />
<corners
android:bottomRightRadius="20dp"
android:topRightRadius="20dp"/>
</shape>
android:background="@drawable/question_back" to the main.xml view @ id="@+id/question" question_back.xml to radius the left side corners: android:background =“ @ drawable / question_back”到main.xml视图@ id =“ @ + id / question” question_back.xml半径为左角:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:dither="true" >
<gradient
android:angle="90"
android:endColor="#ffffffff"
android:startColor="#ff99ffcc" />
<corners
android:bottomLeftRadius="20dp"
android:topLeftRadius="20dp"/>
</shape>
android:background="@drawable/num_back" to the main.xml view @ all the button views num_back.xml to set the radius of all corners android:background =“ @ drawable / num_back”到main.xml视图@所有按钮视图num_back.xml来设置所有角的半径
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:dither="true" >
<gradient
android:angle="90"
android:endColor="#ffffffff"
android:startColor="#ff99ffcc" />
<corners<corners android:radius="20dp" />
</shape>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.