简体   繁体   English

围绕位图的Android并条机

[英]Android Draw Frame from bitmaps around view

Newbie alert here! 新手提醒在这里!

I am trying to learn the best way to draw a custom border around an image (eg a picture frame) that is comprised of 8 bitmaps- 4 corners + 4 sides that are actually slices that need to be repeated depending on the view size. 我正在尝试学习在由8个位图-4个角+ 4个侧面(实际上是根据视图大小需要重复的切片)组成的图像周围绘制自定义边框的最佳方法。 I understand the best way will be to use a FrameView but I'm not sure about the drawing part, for example how to do the repeating for the images along the sides? 我知道最好的方法是使用FrameView,但是我不确定绘图部分,例如如何对侧面的图像进行重复? Can this be done in XML or do I need to handle OnDraw()? 可以用XML完成吗?还是需要处理OnDraw()? Or should I look at using a 9 patch? 还是应该使用9补丁?

There must be an example somewhere. 某个地方一定有一个例子。

I think use of xml is the better approach. 我认为使用xml是更好的方法。 try like this .. 尝试这样..

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >

    <solid android:color="#EFF2FB" />

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

    <stroke
        android:width="0.5dp"
        android:color="@color/ashColor" />

</shape>

This may help you......... 这可能对您有帮助.........

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM