- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
这是我的布局的样子:
我有一个父 Activity ,它有一个自定义 View (自己处理 onTouch 事件的 view1)和 2 个按钮(view2 和 view3)。 DialogFragment 显示了一个可见的布局,其余部分是透明的。我的对话 fragment 如下所示:
public class FragmentText extends DialogFragment{
public static FragmentText newInstance() {
FragmentText frag = new FragmentText();
frag.setStyle(DialogFragment.STYLE_NORMAL, android.R.style.Theme_Translucent_NoTitleBar);
return frag;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
// instantiate the custom layout
final View layout = inflater.inflate(R.layout.fragment_layout, null);
.....
}
}
布局文件如下所示:
<com.TransparentView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layMain"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="70dp"
android:background="@color/transparent"
android:gravity="bottom"
android:orientation="vertical"
android:paddingBottom="70dp" >
<LinearLayout
android:id="@+id/layContent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_margin="5dp"
android:background="@drawable/bk_text_edit"
android:orientation="vertical"
android:padding="@dimen/margin" >
all my layouts and buttons
</LinearLayout>
</com.TransparentView>
和
public class TransparentView extends LinearLayout {
@SuppressLint("NewApi")
public TransparentView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public TransparentView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public TransparentView(Context context) {
super(context);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
return false; // event get propagated
}
}
当用户在 DialogFragment 的可见布局之外按下时,我想:1.关闭对话框 fragment 2. 将 onTouch 传递给父 Activity 并允许用户与 View 进行交互。
所以基本上,如果我将手指拖到 View1 上,我想关闭对话框并继续我对 view1 的拖动交互。
这有可能实现吗?
LE:这也行不通:
layMain.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
getActivity().dispatchTouchEvent(event);
return false;
}
});
最佳答案
我在使用 BottomSheetDialog 时遇到了同样的问题。我解决了我的问题:
final BottomSheetDialog dialog = getDialog();
final View touchOutside = dialog.findViewById(R.id.touch_outside);
touchOutside.setOnTouchListener((v, event) -> {
getActivity().dispatchTouchEvent(event);
return false;
});
看起来 Finn 的解决方案应该可以正常工作。
关于android - 将 Touch 事件从 DialogFragment View 分派(dispatch)到父 Activity View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24024332/
我对这个话题有点怀疑。 情况: 我进行了一项研究,其中指出 Sencha Touch 2 (further Sencha) 和 DHTMLX Touch (further DHTMLX) 是可供选择的
我的移动应用程序目前在 Sencha Touch 1.1.1 下运行。现在,我想将其升级到 Sencha Touch 2.0。有人可以帮我做这件事吗?升级时我应该注意哪些一般步骤? 另外,是否有帮助该
在他们的文档中找不到指定了所有日期时间格式的位置? 我想要一个日期看起来像这样 13 Jan 2013 我发现了这个模式: date("F j, Y") 但这给了我很长的月份名称。 (不知道为什么他们
我需要一个简单的嵌套 ListView 示例。沿着这条线的东西...... (来源:roosteronacid.com) 当您单击一个项目时,您将转换(滑动)到包含另一个列表的下一个 View /卡片
scons 使用 MD5 哈希值而不是文件修改时间来确定是否需要构建依赖项。 我希望这是默认行为。但是,除了编辑文件以使其不同之外,是否有任何方法可以强制它假设特定文件已过期(相当于“触摸”)? 编辑
我有一个 sencha touch 显示在列表中的联系人列表。然后,当您单击列表中的姓名时,它应该向右滑动并说您好 {联系人姓名}!但是当它现在滑过时,它只是说你好!第 29 行是项目点击的 Acti
我是一名 Ext 老手,但我需要创建一些相当简单的移动应用程序,自然而然我正在研究 sencha touch。 Ting 是 - 大多数示例无法在 Firefox/Opera 中运行。 我很高兴使用
只是想知道在 Sencha Touch 中是否有处理该问题的方法。一个商店,应用不同的过滤器后,商店可以用于不同的地方。 例如: 我有一家商店: Ext.regModel('abc', { f
如何覆盖浏览器后退按钮的功能?我在页面中有导航 View ,我想同步浏览器后退按钮和导航 View 的后退按钮。我可以覆盖导航按钮的功能,但我不知道如何为浏览器返回做同样的事情。 我们将不胜感激。 最
如何使用两个 Action 创建 UIButton。 我知道通过使用 UILongPressGestureRecognizer 我们可以执行 Longpress。 但我的要求是,当我长按 UIButt
如何在 Ext.panel 中动态添加新项目?这是我正在使用的代码; app.views.ViewItem = Ext.extend(Ext.Panel, { id: '0', doc
我有一个全屏按钮(我将其放置在 IB 中),其中包含一个图像,当用户单击它时,我希望将其滑出屏幕。我知道连接正常,因为单击按钮时我可以记录一些内容。但是我之前用来移动 UIViews 和 UIImag
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be
大家好,我目前正在为 iPhone 开发一款节奏游戏,只是想知道是否有人对用于 react 时间的最佳作品有任何想法。 我已经完成了所有编码,并将其范围缩小到大约 2 种方式: 1:使用绕过 UICo
我正在尝试使用XCode编码计算器,但是后来我看到带有逗号的数字只是在逗号后被切掉了。 我正在用文本代码获取带有此代码的数字。 -(IBAction)Additionbutton:(id)sender
Sencha Touch 中是否有控件可以显示如下图所示的密码字段? 最佳答案 不,没有本地组件可以做到这一点。但是您可以自己构建它:它是一个包含 4 个输入字段和十几个按钮的表单。有关详细信息,请参
出于某种原因,我的表单面板没有显示。谁能帮忙?如果这很明显,我是新手,很抱歉!它是用 Sencha Architect 构建的,但我不明白为什么没有字段显示在表单中?... Ext.define('M
我创建了一个基于表格的模板,因此我可以获得类似网格的感觉。我的问题是,当我单击表格行时,如何弹出警报(带有 td 信息)。 这是我的 getUserList.js 文件 Ext.regMode
他们无论如何要更改圆形矩形按钮的白色部分而不制作自定义按钮吗? 最佳答案 嗯,差不多。您必须将其设置为自定义但不继承 UIButton。那么你应该能够做类似的事情 myButton.layer.cor
有人可以给我指点 Sencha Touch 和 Javascript 的初学者教程吗?我对 HTML 和 Javascript & CSS 知之甚少。我需要学习高级 Javascript 和指南针/主
我是一名优秀的程序员,十分优秀!