English 中文(简体)
和机器人合并 2 图像
原标题:android merging 2 images

i m working on this for hours and can t solve it. i want to merge 2 images in an XML file - so this will be the basic xml file for my shape. i want this shape to include a png which is the frame, and a png which is a picture inside a frame. that picture will change dynamically.

i ve tried to use tag and to build my shape, but when i m including it to my main xml file it fails because i can use merge only as root. try to did the same with , and still didn t get what i wanted...

我还能做些什么才能合并这两个小便, 才能在框架 png 中设置内部的小便位置?

EDITED: some code:

<ImageView  
    android:layout_width="match_parent" 
    android:layout_height="match_parent"             
    android:src="@drawable/userprofilepicture"
    android:scaleType="fitXY" 
    android:contentDescription="@string/SmallLogo" />


<ImageView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:contentDescription="@string/SmallLogo"
    android:scaleType="fitXY"
    android:padding="30dp"
    android:src="@drawable/questionmark" />

</FrameLayout>

this is my frame and inner pic xml source.. when looking at it inside the graphical layout it looks good. when including it in my main xml file, from somereason it flips the image... ???

这是我的主 xml 的一部分 :

        <TableRow>

        <ImageView
            android:layout_gravity="center_vertical"
            android:layout_marginTop="2.5dp"
            android:contentDescription="@string/SmallLogo"
            android:src="@drawable/logosmall" />

        <ImageView
            android:layout_gravity="center_vertical"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="2.5dp"
            android:contentDescription="@string/slogen"
            android:src="@drawable/slogen" />

        <include layout="@drawable/userprofilepicture"
            android:layout_width="30dp"
            android:layout_height="30dp"/>

    </TableRow>
最佳回答

创建框架Layout 自定义类。 此类将具有框架外观的所有 XML 属性 。

com.package.example;

public class PictureFrame extends FrameLayout {

    public PictureFrame(Context c, AttributeSet attrs) {
        super(c, attrs);
        LayoutInflater inflater = (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        //This adds the image views as you ve styled them in the XML file
        inflater.inflate(R.layout.myFrameImages, this);
    }

    public void setInnerImage(int resource) {
        ImageView ivInner = (ImageView) findViewById(R.id.innerImage);
        ivInner.setImageResource(resource);
    }

}

您的 XML 文件看起来像

<ImageView
     android:src="@drawable/myFrameImage"
     android:layout_height="fill_parent"
     android:layout_width="fill_parent"
     android:scaleType="fitXY"/>
<ImageView
     android:src="@drawable/myInnerImage"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:scaleType="fitXY"
     android:layout_margin="10dp"
     android:id="@+id/innerImage"/>

您也可以创建自己的 XML 属性, 用于您在 XML 中声明时, 直接在 xml 中声明内部图像。 如果您需要帮助, 您需要联系我或张贴另一个问题 。

问题回答




相关问题
how to represent it in dtd?

I have two element action and guid. guid is a required field when action is add. but when action is del it will not appear in file. How to represent this in dtd ?

.Net application configuration add xml-data

I need to add xml-content to my application configuration file. Is there a way to add it directly to the appSettings section or do I need to implement a configSection? Is it possible to add the xml ...

XStream serializing collections

I have a class structure that I would like to serialize with Xstream. The root class contains a collection of other objects (of varying types). I would like to only serialize part of the objects that ...

MS Word splits words in its XML format

I have a Word 2003 document saved as a XML in WordProcessingML format. It contains few placeholders which will be dynamically replaced by an appropriate content. But, the problem is that Word ...

Merging an XML file with a list of changes

I have two XML files that are generated by another application I have no control over. The first is a settings file, and the second is a list of changes that should be applied to the first. Main ...

How do I check if a node has no siblings?

I have a org.w3c.dom.Node object. I would like to see if it has any other siblings. Here s what I have tried: Node sibling = node.getNextSibling(); if(sibling == null) return true; else ...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

热门标签