Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/225.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android中的圆角imageview 我正在尝试创建一个圆角视图 我试图通过XML来设置它,而不是通过编程来设置它 我已经为我的推荐人设定了背景_Android_Xml - Fatal编程技术网

android中的圆角imageview 我正在尝试创建一个圆角视图 我试图通过XML来设置它,而不是通过编程来设置它 我已经为我的推荐人设定了背景

android中的圆角imageview 我正在尝试创建一个圆角视图 我试图通过XML来设置它,而不是通过编程来设置它 我已经为我的推荐人设定了背景,android,xml,Android,Xml,是否无法通过xml设置圆角?我们必须使用位图? 活动\u main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android

是否无法通过
xml
设置圆角?我们必须使用
位图


活动\u main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center"
    android:orientation="vertical" >

    <FrameLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/round_cornered_imageview"
            android:src="@drawable/image" />

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="My-Text"
            android:textColor="@color/textbody"
            android:layout_gravity="bottom|center"
            android:textSize="40sp" />

        <Button
            android:id="@+id/button1"
            android:layout_width="108dp"
            android:layout_height="74dp"
            android:background="@color/textbody"
            android:layout_gravity="top|center"
            android:text="Button" />

    </FrameLayout>

</LinearLayout>
<?xml version="1.0" encoding="UTF-8"?> 

    <shape xmlns:android="http://schemas.android.com/apk/res/android" 
         android:shape="rectangle" >


        <corners android:bottomRightRadius="10dp" android:bottomLeftRadius="10dp" 
         android:topLeftRadius="10dp" android:topRightRadius="10dp"/>

          <stroke
            android:color="@color/black"
            android:width="1dp"

             />

    </shape>

输出

我所尝试的

rounded\u corned\u imageview.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center"
    android:orientation="vertical" >

    <FrameLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/round_cornered_imageview"
            android:src="@drawable/image" />

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="My-Text"
            android:textColor="@color/textbody"
            android:layout_gravity="bottom|center"
            android:textSize="40sp" />

        <Button
            android:id="@+id/button1"
            android:layout_width="108dp"
            android:layout_height="74dp"
            android:background="@color/textbody"
            android:layout_gravity="top|center"
            android:text="Button" />

    </FrameLayout>

</LinearLayout>
<?xml version="1.0" encoding="UTF-8"?> 

    <shape xmlns:android="http://schemas.android.com/apk/res/android" 
         android:shape="rectangle" >


        <corners android:bottomRightRadius="10dp" android:bottomLeftRadius="10dp" 
         android:topLeftRadius="10dp" android:topRightRadius="10dp"/>

          <stroke
            android:color="@color/black"
            android:width="1dp"

             />

    </shape>

但它不起作用。。。我需要在哪里更正自己?

您可以按照以下操作: 在依赖项中的渐变上

在xml文件上



我这边的工作可能很好。但因为我有背景图像。。。。在我的输出中是这样的吗?检查这个链接这里是另一个链接