我愿做以下Android上:
I would like to do the following on Android:
什么是实现,最好的方法是什么?
What would be the best way to accomplish that?
要我所知的图像可被设置为onClickListener / onTouchListener,一旦的onClick / onTouch被调用时,我应该能够将图标添加到该位置,其中图标的图像并设定为onTouchListener作为好。当我点击了图片上,一个EditText应该出现 - 不知道如何使动态虽然它扩大?一旦文本输入和一个按钮后,整个图像 - 与的EditText文本 - 应保存 - 我会怎么做呢?在画布上画出?
To my knowledge the image can be set to an onClickListener/onTouchListener, and once onClick/onTouch is called, I should be able to add an icon to that location, where the icon is an image and is set to an onTouchListener as well. When I click on that image, an edittext should appear - not sure how to make it expand dynamically though? Once the text is entered and a button is clicked, the entire image - with the text in the edittext - should be saved - how would I do that? Draw on a canvas?
帮助将是非常美联社preciated! :)
Help would be highly appreciated! :)
推荐答案第1步
您视图应该是一个的RelativeLayout内部,以便将它们彼此的顶部。当你preSS您的ImageView,小单将被设置为可见(它必须是XML文件或编程内不可见)。
Your Views should be inside a RelativeLayout in order to place them top of each other. When you press your ImageView, small one will be set to Visible (it must be invisible inside xml file or programmatically).
imgV.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { imageViewButton.setVisibility(View.VISIBLE); } });第2步
在preSS小的图像,会的EditText变得可见。同上instucted。
When you press small image, EditText will become visible. Same as instucted above.
imageViewButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { editText.setVisibility(View.VISIBLE); } });第3步
在打字的时候,如果你设置宽度match_parent和高度WRAP_CONTENT你的EditText自动扩展。
Your EditText expands automatically when typing if you set width to match_parent and height to wrap_content.
<EditText android:id="@+id/editText1" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" > </EditText>第四步
当您想要保存您的布局,在你的onClick事件实现这一点。 (在下面的例子中,它是一个的LinearLayout,但你将有一个RelativeLayout的,我想你可以根据自己的需要改变它)
When you want to save your Layout, implement this in your onClick event. (In the example below, it is a LinearLayout but you will have a RelativeLayout, I suppose you can change it according to your needs)
据对How到布局视图图像或PDF格式保存到SD卡中的Android?
添加权限在manifest文件
Add permission in the manifest file
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />使用以下
LinearLayout content = findViewById(R.id.rlid); content.setDrawingCacheEnabled(true); Bitmap bitmap = content.getDrawingCache(); File file,f; if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) { file =new File(android.os.Environment.getExternalStorageDirectory(),"TTImages_cache"); if(!file.exists()) { file.mkdirs(); } f = new File(file.getAbsolutePath()+file.seperator+ "filename"+".png"); } FileOutputStream ostream = new FileOutputStream(f); bitmappress(CompressFormat.PNG, 10, ostream); ostream.close(); } catch (Exception e){ e.printStackTrace(); }更多推荐
展开一个EditText动态
发布评论