android - 如何将角半径应用于线性布局

标签 android android-layout

我想制作一个带有圆形边框的布局。如何在 LinearLayout 中应用特定大小的半径?

最佳答案

您可以在 drawable 文件夹中创建 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>

这是我通常在我的应用程序中做的事情。

关于android - 如何将角半径应用于线性布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10074249/

相关文章:

android - 打开附件时如何解决 Yahoo Mail Provider 的权限拒绝问题?

c# - Xamarin.Forms - HttpClient SendAsync 中未处理的异常

Android 复选框样式

android - 如何在 Android 中为不同的分辨率使用不同的背景图片?

Android 自适应 ImageView 尺寸到屏幕尺寸

android - 如何更改 android::CoordinatorLayout 屏幕

android - 刷新listview/显示新添加的数据到listview android

android - 尝试在空对象引用上调用虚方法 - 全局变量类

android - 带有元音变音字符的 Gradle.properties

android - ExpandableListView 子项目的 CheckBox 被随机检查