如何显示全屏图像视图onlclick
我相当新的xamarin.android,我有一个滚动视图中的图像视图,我想单击放大它。 (在手机脸书上显示完整图像onclick),当用户点击图像时,我希望它在全屏中打开。我该如何实现?如何显示全屏图像视图onlclick
我做了一些研究,找不到一些有用的线程..任何帮助将appriciated谢谢你提前。
我的继承人detailactivity类
private ImageView mtimg0, mtimg1, mtimg2, mtimg3, mtimg4, mtimg5;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.detailLayout);
FindViews();
Android.Content.Intent i = this.Intent;
string iname = i.Extras.GetString("MTNAME");
int iimg0 = i.Extras.GetInt("IMG0");
int iimg1 = i.Extras.GetInt("IMG1");
int iimg2 = i.Extras.GetInt("IMG2");
int iimg3 = i.Extras.GetInt("IMG3");
int iimg4 = i.Extras.GetInt("IMG4");
int iimg5 = i.Extras.GetInt("IMG5");
mtimg0.SetImageResource(iimg0);
mtimg1.SetImageResource(iimg1);
mtimg2.SetImageResource(iimg2);
mtimg3.SetImageResource(iimg3);
mtimg4.SetImageResource(iimg4);
mtimg5.SetImageResource(iimg5);
}
private void FindViews()
{
tmtname = FindViewById<TextView>(Resource.Id.mtname);
mtimg0 = FindViewById<ImageView>(Resource.Id.mtimg00);
mtimg1 = FindViewById<ImageView>(Resource.Id.mtimg01);
mtimg2 = FindViewById<ImageView>(Resource.Id.mtimg02);
mtimg3 = FindViewById<ImageView>(Resource.Id.mtimg03);
mtimg4 = FindViewById<ImageView>(Resource.Id.mtimg04);
mtimg5 = FindViewById<ImageView>Resource.Id.mtimg05);
}
}
EDITED
这里是我的列表视图在那里我取得我的所有图片
class MountainsData
{
public static List<Mountain> MountainList = new List<Mountain>()
{
new Mountain()
{
MtName = "ALTO PEAK",
Masl = 1332,
Difficulty = 6,
Island = 2,
MtImg00 = Resource.Drawable.altopeak,
MtImg01 = Resource.Drawable.altopeak1,
MtImg02 = Resource.Drawable.altopeak2,
MtImg03 = Resource.Drawable.altopeak3,
MtImg04 = Resource.Drawable.altopeak4,
Location = "ORMOC, LEYTE",
JumpOff ="Lake Danao National Park, Ormoc",
Description ="LLA: 11.1061 N, 124.7097 E, 1332
}
,并在项目的例子我列表视图活动..这里是我如何将每个项目传递给我的详细活动...并在我的详细活动中接收它我正在使用代码abo VE(在detailactivity类。在这个问题上面的第一个代码)
什么,我想里面detailactivity发生的是,当我点击的ImageView ..在全屏幕显示,但我不能找到一种方法,正确地传递字符串..预先感谢您:d
这是一个DialogFragment解决方案:
你fragment_dialog.axml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minWidth="2000dp"
android:minHeight="2000dp">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/img"
android:src="@drawable/aaa"
android:scaleType="fitCenter"/>
</LinearLayout>
个
你MyDialogFragment.cs
public class MyDialogFragment : DialogFragment
{
private ImageView imgView;
static public MyDialogFragment newInstance()
{
MyDialogFragment f = new MyDialogFragment();
return f;
}
public override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetStyle(DialogFragmentStyle.NoTitle, Android.Resource.Style.ThemeBlackNoTitleBarFullScreen);
}
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
base.OnCreateView(inflater, container, savedInstanceState);
View v = inflater.Inflate(Resource.Layout.fragment_dialog, container, false);
imgView = v.FindViewById<ImageView>(Resource.Id.img);
//Get int and set it to the ImageView
int imgPassed = Arguments.GetInt("imgId");
imgView.SetImageResource(imgPassed);
return v;
}
}
从您的ItemSelected或点击事件
FragmentTransaction ft = FragmentManager.BeginTransaction();
DialogFragment newFragment = MyDialogFragment.newInstance();
//Declare String and get the Id
string imgName = "bbb"; //Change with the name of the image you want to pass
int imgId = Resources.GetIdentifier(imgName, "drawable", PackageName);
//Pass it with the Bundle class
Bundle bundle = new Bundle();
bundle.PutInt("imgId", imgId);
newFragment.Arguments = bundle;
//Show the Fragment
newFragment.Show(ft, "dialog");
编辑: 我用捆绑类为可能的方式,从通过一个数据活动的碎片。对我来说工作得很好。
另一种方法具有相同的结果只是被使用另一个活动和意图,你可以找到你需要的一切在这里:Passing Data Between Activities
你好先生本·/谢谢你的答案..它帮助了很多..你能告诉我如何从活动传递字符串?因为它似乎没有收到正确的数据。 –
@KeithJustine我编辑了帖子,如果它适合你,请务必将问题标记为已回答。如果你需要更多的帮助,请让我知道:-) –
你好,先生本抱歉,对于迟到的回复,刚从假期回来..你的回答是非常有帮助的,但我仍然在传递字符串时遇到了麻烦..它似乎并没有收到正确的数据..“int iimg5 = i.Extras.GetInt(”IMG5“);”这行代码是如何将我的列表视图中的字符串传递给细节活动..只是想知道如何将它传递给对话框片段? –
[放大上点击一个ImageView的]的可能的复制(http://*.com/问题/ 22409920 /放大-i-imageview-on-click) – Demitrian
或者只是为全屏视图创建一个新的活动。将意图传递给新活动的图像管道或路径。 – user1519979
如果你不想离开你的活动,你也可以在一个片段中展示它...如果你需要一个自定义的解决方案来分享你的项目,你到底做了什么:-) –