首页 > 其他分享 >app直播源代码,Android中点击图片放大的简单方法

app直播源代码,Android中点击图片放大的简单方法

时间:2023-06-21 14:11:05浏览次数:43  
标签:layout app ImageView dialog new imgView Android 源代码 android

app直播源代码,Android中点击图片放大的简单方法

Java代码:

 


public void onThumbnailClick(View v) {
// final AlertDialog dialog = new AlertDialog.Builder(this).create();
// ImageView imgView = getView();
// dialog.setView(imgView);
// dialog.show();
 
 
// 全屏显示的方法
final Dialog dialog = new Dialog(this, android.R.style.Theme_Black_NoTitleBar_Fullscreen);
ImageView imgView = getView();
dialog.setContentView(imgView);
dialog.show();
 
 
// 点击图片消失
imgView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
dialog.dismiss();
}
});
}
private ImageView getView() {
ImageView imgView = new ImageView(this);
imgView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
InputStream is = getResources().openRawResource(R.drawable.thumbnail);
Drawable drawable = BitmapDrawable.createFromStream(is, null);
imgView.setImageDrawable(drawable);
 
 
return imgView;
}

布局文件:

 


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >
 
 
    <ImageView 
        android:layout_centerInParent="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:clickable="true"
        android:src="@drawable/thumbnail"
        android:onClick="onThumbnailClick"/>
</RelativeLayout> 

 

以上就是app直播源代码,Android中点击图片放大的简单方法, 更多内容欢迎关注之后的文章

 

标签:layout,app,ImageView,dialog,new,imgView,Android,源代码,android
From: https://www.cnblogs.com/yunbaomengnan/p/17496083.html

相关文章