【发布时间】:2012-09-15 01:03:14
【问题描述】:
我在线性布局中有一个 textview 和 imageview。 Textview 在顶部,imageview 在底部。我使用下面的线为线性布局设置圆角。但是 imageview 的角不是圆角的。我看到只有线性布局的顶角是四舍五入的。 我怎样才能使 imageview 的底角变圆?(如果我删除 imageview,我看到所有的角都是圆的)
rounded_corners.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#ffffff" />
<corners
android:bottomLeftRadius="8dp"
android:bottomRightRadius="8dp"
android:topLeftRadius="8dp"
android:topRightRadius="8dp" />
</shape>
main.xml
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="50dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="50dp"
android:background="@xml/rounded_corners"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="xxxxxxxx" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:src="@drawable/my_image_view" />
</LinearLayout>
屏幕截图:
【问题讨论】:
-
如果您将圆角形状设置为布局的背景并且在输出中它不是圆角,则不太可能。您能否上传当前输出的快照。
-
我看过那个例子。为什么我们不能在 xml 中带来相同的效果?我哪里错了?
-
@user1670443 我不认为这可以在 xml 中实现,除非您将图像编辑为圆角。
-
我认为问题是您已将 centercrop 设置为 imageview。
标签: android imageview android-linearlayout rounded-corners