我正在开发一个Application.My要求是显示图像和字符串(标题和字幕).图像和字符串都被下载和解析然后显示.我正在使用Hashmap<ImageView, String>/目前我能够在ListView中显示图像,但我不知道如何根据Image显示字符串.请帮助我如果有人有逻辑.
谢谢.
阿布舍克
我正在尝试使用异步请求从URL中获取图像,以防止URL挂起.这是我正在使用的代码片段
private void setImg(final ImageView im, String url){
AsyncHttpClient client = new AsyncHttpClient();
client.get(url, new AsyncHttpResponseHandler(){
public void onSuccess(String response){
try{
byte[] imageAsBytes = response.getBytes();
im.setImageBitmap(BitmapFactory.decodeByteArray(imageAsBytes, 0, imageAsBytes.length));
im.refreshDrawableState();
} catch(Throwable e){
e.printStackTrace();
}
}
});
}
Run Code Online (Sandbox Code Playgroud)
这总是在logcat中显示此警告
12-29 01:55:33.043: D/skia(14414): --- SkImageDecoder::Factory returned null
我找不到合适的理由.有帮助吗?
我在LoaderManager中使用CursorLoader和Custom CursorAdapter.我已经实现了显示专辑和相关的艺术家,现在我想显示封面.
这是我的Custom CursorAdapter:
public class AlbumsAdapter extends CursorAdapter {
private final LayoutInflater mInflater;
public AlbumsAdapter(Context context, Cursor c) {
super(context, c);
mInflater=LayoutInflater.from(context);
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
TextView albumTitle =(TextView)view.findViewById(R.id.albumTextView);
albumTitle.setText(cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Albums.ALBUM)));
TextView artistName=(TextView)view.findViewById(R.id.artistTextView);
artistName.setText(cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Albums.ARTIST)));
ImageView albumCover=(ImageView)view.findViewById(R.id.artistTextView);
// Here what should I do ?
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
final View view=mInflater.inflate(R.layout.albums_row,parent,false);
return view;
}
}
Run Code Online (Sandbox Code Playgroud)
我试过以下但没有成功:
String path = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Albums.ALBUM_ART));
File imgFile = new File(path);
if(imgFile.exists()){
Bitmap …Run Code Online (Sandbox Code Playgroud) android albumart android-imageview android-mediaplayer android-cursorloader
我是stackoverflow的新手.我的Android应用程序有点问题,特别是使用ImageView触发事件.此事件打开一个带有一些预先写好的文本的电子邮件客户端,它应该附加图像的图像.我已经知道图像应该先转换成位图,然后压缩并发送到电子邮件客户端,但不幸的是我不是Android/Java专家,所以我找不到如何做到这一点.这是电子邮件方法的代码:
下面的新代码
我必须替换"String imageURI = null;" 以及电子邮件需要的图像.谢谢你们!
编辑:
我设法编辑了我的代码,没有错误:
public void sendMail(ImageView image){
Intent i = new Intent(Intent.ACTION_SEND);
int imageURI = R.drawable.img1;
i.setType("text/plain");
i.putExtra(Intent.EXTRA_EMAIL , new String[]{"destinatario@globelife.biz"});
i.putExtra(Intent.EXTRA_SUBJECT, "Oggetto");
i.putExtra(Intent.EXTRA_TEXT , "Globelife");
i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
i.setType("image/jpeg");
i.putExtra(Intent.EXTRA_STREAM, Uri.parse("android.resource://"+getPackageName()+"/"+imageURI));
try {
startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(Test01Activity.this, "Non sono presenti app per l'invio di e-mails.", Toast.LENGTH_SHORT).show();
}
}
Run Code Online (Sandbox Code Playgroud)
但我需要更改"int imageURI = R.drawable.img1;" to"int imageURI = ImageView.src;" 或类似的东西
我收到错误"无法将@ drawable/12234转换成drawable",其中12234是我的图像名称,放在drawable文件夹中.
我能够分配更小的其他图像,但是当我尝试分配此图像时,它会给我一个错误.
这是我的Imageview xml的代码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView4"
android:layout_alignParentTop="true"
android:src="@drawable/12234"
android:adjustViewBounds="true"
android:longClickable="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true" />
Run Code Online (Sandbox Code Playgroud)
我正在尝试用wave动画创建一个按钮。我不想更改图像的大小,而是要从图片和外部进行波浪效果。
我尝试了这个:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<objectAnimator
android:propertyName="scaleX"
android:duration="2000"
android:valueFrom="1.0"
android:valueTo="1.3"
android:repeatMode="reverse"
android:repeatCount="infinite"
android:valueType="floatType" />
<objectAnimator
android:propertyName="scaleY"
android:duration="2000"
android:valueFrom="1.0"
android:valueTo="1.3"
android:repeatMode="reverse"
android:repeatCount="infinite"
android:valueType="floatType" />
Run Code Online (Sandbox Code Playgroud)
但这会更改图像的大小,而不是发送图像。
我想要这样的东西:

我试图让馅饼的每个切片成为一个按钮.馅饼是图像视图中的一堆矢量drawables.我不一定需要点击实际的饼图片.我正在考虑使用Path绘制透明形状并将其放在顶部并将其设为按钮,但据我所知,drawables无法点击.
我读了一篇博文,其中显然使用路径来制作自定义形状的图像视图,我知道图像视图是可点击的,但似乎在博客文章中的实现图像视图仍然是矩形的,但博客使用的位图在示例中,只是在图像视图内修剪为自定义形状.这是我所指的帖子:http://www.androidhub4you.com/2014/10/android-custom-shape-imageview-rounded.html
请像五岁那样向我解释一下.我对编程比较陌生.如果不是Android Studio的自动一切,我不会在这里.
谢谢.
android view android-imageview android-button onclicklistener
我在我的应用程序中使用圆形image_View,但是当image_View图像的选择图像不适合image_View时
这个image_View:(xml)
<ImageView
android:id="@+id/user_profile_pic"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_below="@+id/user_cover_pic"
android:layout_centerHorizontal="true"
android:layout_marginTop="-60dp"
android:background="@drawable/circular_border"
android:elevation="6dp"
android:scaleType="centerCrop"
android:padding="10dp"
android:src="@drawable/ghasem"
tools:ignore="ContentDescription,UnusedAttribute" />
Run Code Online (Sandbox Code Playgroud)
这个圆形边界:
<
?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="100dp" />
<solid android:color="#fff" />
<stroke
android:width="3dip"
android:color="@color/colorAccent" />
<padding
android:bottom="4dp"
android:left="4dp"
android:right="4dp"
android:top="4dp" />
</shape>
Run Code Online (Sandbox Code Playgroud)
我有一个带有工具栏的活动,在该工具栏中,我添加了一个图像视图并在其中设置了徽标。
我还创建了不同的片段,现在当我看到片段时,我想隐藏该图像视图并将标题设置为活动的工具栏。
我已经将图像视图和工具栏设置为家庭活动中的public static。
我试图像这样访问工具栏:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_account, container, false);
final Toolbar toolbar = (Toolbar) ((HomeActivity) getActivity()).findViewById(R.id.toolbar);
toolbar.setTitle(R.string.menu_account);
((HomeActivity) getActivity()).setSupportActionBar(toolbar);
((HomeActivity) getActivity()).mLogo.setVisibility(View.GONE);
return view;
}
Run Code Online (Sandbox Code Playgroud)
但是我在图像视图上得到了一个空指针,如果注释了setVisibility(View.GONE),则可以在工具栏上看到图像。
家庭活动
public class HomeActivity extends AppCompatActivity{
public static Toolbar toolbar;
public static ImageView mLogo;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
mLogo = (ImageView)findViewById(R.id.imageViewLogo);
FragmentManager fragmentManager = HomeActivity.this.getFragmentManager();
MainFragment fragment …Run Code Online (Sandbox Code Playgroud) java android android-imageview android-fragments android-toolbar
图像视图背景仅反映在不在圆圈外的圆圈内.我尝试了很多东西但却做不到.有人请我.谢谢!!