我想做一个圆角边框的布局。如何在LinearLayout
中应用特定大小的半径
发布于 2012-04-09 22:20:18
可以在可绘制文件夹中创建XML文件。例如,将其命名为shape.xml
在shape.xml
中
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid
android:color="#888888" >
</solid>
<stroke
android:width="2dp"
android:color="#C4CDE0" >
</stroke>
<padding
android:left="5dp"
android:top="5dp"
android:right="5dp"
android:bottom="5dp" >
</padding>
<corners
android:radius="11dp" >
</corners>
</shape>
<corner>
标签用于您的特定问题。
根据需要进行更改。
在你的whatever_layout_name.xml
中
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="5dp"
android:background="@drawable/shape" >
</LinearLayout>
这是我在应用程序中通常做的事情。希望这能帮上忙。
发布于 2012-04-09 21:57:51
您将使用Shape Drawable作为布局的背景并设置其cornerRadius。Check this blog获取详细的教程。
发布于 2018-03-17 15:40:47
布局
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="300dp"
android:gravity="center"
android:layout_height="300dp"
android:layout_centerInParent="true"
android:background="@drawable/rounded_edge">
</LinearLayout>
可绘制文件夹rounded_edge.xml
<shape
xmlns:android="http://schemas.android.com/apk/res/android">
<solid
android:color="@android:color/darker_gray">
</solid>
<stroke
android:width="0dp"
android:color="#424242">
</stroke>
<corners
android:topLeftRadius="100dip"
android:topRightRadius="100dip"
android:bottomLeftRadius="100dip"
android:bottomRightRadius="100dip">
</corners>
</shape>
https://stackoverflow.com/questions/10074249
复制相似问题