- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我在线性布局中有一个 TextView 和一个 ImageView 。 Textview 在顶部,imageview 在底部。我使用下面的线条为线性布局设置圆角。但是 imageview 角不是圆的。我只看到 linearlayout 的顶角是圆角的。 我怎样才能使 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>
主.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>
屏幕截图:
最佳答案
你可以把图片的左下角和右下角做成圆角,像这样:
代码:
public static Bitmap getRoundCornerBitmap(Bitmap bitmap, int radius) {
int w = bitmap.getWidth();
int h = bitmap.getHeight();
Bitmap output = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(output);
final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
final RectF rectF = new RectF(0, 0, w, h);
canvas.drawRoundRect(rectF, radius, radius, paint);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
canvas.drawBitmap(bitmap, null, rectF, paint);
/**
* here to define your corners, this is for left bottom and right bottom corners
*/
final Rect clipRect = new Rect(0, 0, w, h - radius);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
canvas.drawRect(clipRect, paint);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
canvas.drawBitmap(bitmap, null, rectF, paint);
bitmap.recycle();
return output;
}
此方法可以为您提供左下角和右下角圆角的图像。
关于android - android中Imageview的圆角,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12550311/
我有一个包含各种子元素的网格,例如网格、Stackpanel、图像...是否可以以裁剪所有内容的方式将网格的角变圆?此外,根网格的大小可能会有所不同,因此无法进行硬编码。 编辑:经过大量搜索,我发现这
我的应用程序采用非常圆润的字体设计,我希望使用勾选框作为 UI 的一部分。带有完全圆形勾选“框”的设计看起来不太好。我正在寻找圆角的标准勾选框,就像您使用容器一样。关于如何实现这一目标的任何想法。我试
我的应用程序采用非常圆润的字体设计,我希望使用勾选框作为 UI 的一部分。带有完全圆形勾选“框”的设计看起来不太好。我正在寻找圆角的标准勾选框,就像您使用容器一样。关于如何实现这一目标的任何想法。我试
所以我应该显示一个时间表,其中每个项目都有一个带有圆角的背景图像...... 我不知道如何为我的 View (当前是 TextView,但我可以更改它)提供背景(这是必须重复的图案)并为其提供圆角..
我想让 JTextArea 有一个圆角,我做了这段代码: public BPosTxtArea() { super(); setOpaque(false); } @Override p
我有两个项目,我在其中创建了一组扩展 card 类的自定义 cards,然后将它们插入到 StaggeredView 中。 我的问题是,在其中一个项目中,卡片角会自动变圆,而在另一个项目中则不会! 此
我正在寻找一些 c++ 绘图图形库来为动态键盘键创建器创建带有抗锯齿选项的圆角。我已经测试过 OpenCV 和 Magick++ 函数,但结果不是很好。谁能帮我解决这个问题? 这是一个使用 Magic
有没有办法使 QLineEdit 小部件的角变圆?如果没有,是否有类似的小部件我可以这样做? 视觉意义: 已解决:(请参阅下面的更多信息) QLineEdit *lineEdit = ne
我正在尝试创建具有圆角和背景的矩形作为重复位图。我是这样写的,但是在角落里得到了位图。 有人能帮忙吗? 背景.xml 最
我有 UIVIew 的代码: override func drawRect(rect: CGRect) { let toolbarSize = CGFloat(UIDevice.current
我正在开发一个 Windows 窗体应用程序(C#、.NET 4.0、VS 2010),其中我有一个非常标准的 MainForm 和一个 ToolStrip(GripStyle:Hidden,Dock
我设法绘制了一个矩形 :-) 但我不知道如何绘制圆角矩形。 谁能帮我解决以下如何四舍五入矩形的代码? let canvas = UIGraphicsGetCurrentContext() rec =
我有以下 SVG: 我想获得类似 CSS 的 border-top-right-radius 和 border-top-bottom-radius 效果。 如何实现
这个问题在这里已经有了答案: How to make an ImageView with rounded corners? (58 个回答) 关闭去年。 我希望图像具有圆角。我实现了这个 xml 代码
我使用此类别并为我的 UITableView 创建大小相同的图像。有没有办法让图像也有圆角?谢谢! + (UIImage *)scale:(UIImage *)image toSize:(CGSize
我对 iPhone 屏幕设计没有太多经验,但我需要制作一个像这样的表格:(图片),我进行了调查,但没有找到任何东西。该表需要有一个圆角,用户将能够插入数据,在本例中是名字、姓氏等......现在我使用
创建具有自定义背景图像的 NSButton 的最佳方法是什么,它能够具有可变的宽度,而不会使角边框看起来被拉伸(stretch)?我知道有一些方便的方法可以使用 UIButton 执行此操作:http
我知道你可以使用 .cornerRadius()将 swiftUI View 的所有角都圆角,但有没有办法只圆角特定的角,例如顶部? 最佳答案 有两个选项,您可以使用 View与 Path ,或者您可
我想在我的游戏屏幕上添加一些黑色轮廓,使其看起来像圆角。 这是我想要达到的效果: 我认为使用着色器可能很容易创建这种效果,而不是在所有内容之上绘制一个巨大的位图。 有人可以帮助我使用此效果的 GLSL
我的 NSTextField 有圆角和白色背景颜色,但 View 本身似乎是矩形的。这意味着圆角和边界矩形之间的空间显示为透明。我该如何填写该区域才能使其不突出? 图片: 代码: let textFi
我是一名优秀的程序员,十分优秀!