本文介绍了如何添加布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

您好我想一个布局添加到我的活动。

我有一个的FrameLayout,我添加一个SurfaceView至今。

现在我想通过它添加另一个布局作为菜单所以当我点击我的面查看我将它设置为可见的按钮。

此布局应包含一个TextView的,应当滚动

1:什么是这种方法的最佳LAyoutout的事情吗?我想在这里我想补充一个字符串列表视图动态

2:我怎样才能在code ++实现这个

它应该是:

滚动。
应该是具有一定规模:一半屏幕宽度的一半的screenHeight的
所以它也应当是在位置屏幕宽度/ 4和screenHeight / 4
要做到这一点,我可以把我的mainThread内这些参数连接到surfaceview所以我必须在像素格式是没有问题的媒体链接所需要的参数。
当用户点击该视图之外应松专注所以我surfaceView得到Focusagain和布局设置了。

因此​​,它应该是这样的:

用户点击该按钮可显示菜单
现在,用户可以通过滚动菜单
当他presses的后退按钮或外部视图应该关闭自己
当存在应该显示它应附加到布局的新文本要准备在用户再次点击按钮的下一次要显示

感谢您


解决方案

That sounds good to me, you can go with either ListView or RecyclerView. You are basically not adding TextViews dynamically, you create an adapter that will do handle creating and recycling of views for you.

Create a DialogFragment, it's the best candidate for such dialogs with logic. Its lifecycle is handled via FragmentManager, so you won't have issues on screen rotations and so on. It allows you setting whatever layout you need just like any other Fragment. It will be placed in the center for you, so you don't have to handle that manually. Just set the size of the dialog you want and it will look perfect.

I don't really get this one. When user touches outside, do you need to lose the focus but the dialog should not be closed? If yes, then this is already answered here:

Allow outside touch for DialogFragment

If the dialog should be closed, you don't have to implement anything, it works like that by default.

这篇关于如何添加布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 14:25