Android 创建一个非全屏的模式窗口
我试着模仿iphone屏幕,当你点击更多的照片时,屏幕会弹出钛合金。我认为这是一个“模态窗口”。目前,我已经尝试并创建了一个只有几个按钮的模式窗口。稍后我将介绍图标。但是模态窗口占据了整个屏幕,我试图调整它的大小,但是没有效果。。非常感谢您提供有关如何重现左侧屏幕的任何建议: 我也想尝试在Android中复制类似的东西。我的原始代码如下:Android 创建一个非全屏的模式窗口,android,ios,window,titanium,modal-dialog,Android,Ios,Window,Titanium,Modal Dialog,我试着模仿iphone屏幕,当你点击更多的照片时,屏幕会弹出钛合金。我认为这是一个“模态窗口”。目前,我已经尝试并创建了一个只有几个按钮的模式窗口。稍后我将介绍图标。但是模态窗口占据了整个屏幕,我试图调整它的大小,但是没有效果。。非常感谢您提供有关如何重现左侧屏幕的任何建议: 我也想尝试在Android中复制类似的东西。我的原始代码如下: var ModalWindow = Ti.UI.createWindow({ title:'modal window',
var ModalWindow = Ti.UI.createWindow({
title:'modal window',
backgroundColor:'black',
height: "80%",
width: '200dp'
});
var PlayStoreBtn= Titanium.UI.createButton({
title: 'Play Store',
top: '10%'
});
var youTubeBtn= Titanium.UI.createButton({
title: 'YouTube',
top: '20%'
});
var facebookBtn= Titanium.UI.createButton({
title: 'Facebook',
top: '30%'
});
var mySpaceBtn= Titanium.UI.createButton({
title: 'MySpace',
top: '40%'
});
var twitterBtn= Titanium.UI.createButton({
title: 'Twitter',
top: '50%'
});
var deleteBtn= Titanium.UI.createButton({
title: 'Delete',
top: '60%'
});
var cancelBtn= Titanium.UI.createButton({
title: 'Cancel',
top: '70%'
});
cancelBtn.addEventListener("click", function (e){
ModalWindow.close();
})
ModalWindow.add(PlayStoreBtn);
ModalWindow.add(youTubeBtn);
ModalWindow.add(facebookBtn);
ModalWindow.add(mySpaceBtn);
ModalWindow.add(twitterBtn);
ModalWindow.add(deleteBtn);
ModalWindow.add(cancelBtn);
ModalWindow.open({modal:true});
});
要创建不占用整个屏幕的模式窗口,请不要使用Ti.UI.window组件!这些都是重量级拳手的方式。使用Ti.UI.View 这是一个跨平台视图,显示一个模式窗口,该窗口仅占据80%的高度,嵌套在屏幕底部,它还阻止模式下任何内容的所有输入:
module.exports = function() {
var background = Ti.UI.createView({
backgroundColor : '#000',
opacity : 0.4,
width : Ti.UI.FILL,
height : Ti.UI.FILL
});
var container = Ti.UI.createView({
width : Ti.UI.FILL,
height : Ti.UI.FILL
});
// This is the view that contains all the buttons and shows up
// It lays on top of the transparent background
var modal =Ti.UI.createView({
width : Ti.UI.FILL,
height : 80%,
bottom : 0,
background : '#555,
borderColor : '#888',
borderRadius : 8,
borderWidth : 8,
...More styling, maybe even a background image...
});
...Add your buttons to the modal here...
container.add(background);
container.add(modal);
return container;
};
像这样使用它,假设它位于名为Modal.js的文件中
var Modal = require('Modal');
var modalView = new Modal();
下面是一个小部件教程,它将向您展示如何布局图标。 底部是完整的代码 这段代码应该向您展示如何在视图之间交换,以便您可以拥有多个视图屏幕
我看到过多个视图的更好例子,但我找不到一个我不想分享任何信息。我只是用那个图片作为我想要实现的模态窗口类型的一个例子。你发给我的android链接似乎都是java的,但正如我在问题中所说的。我使用的是钛平台。如果你想要那种类型的模态窗口(不是为了共享),那么你必须在Photoshop/Illustrator中自己设计。我在答案中举了一个制作模态窗口的例子。试试那个。好的,谢谢,我现在就试试这个。我想你必须将modalView添加到窗口??i、 e.moreBtn.addEventListener(“单击”,函数(e){var Modal=require('Modal');var modalView=new Modal();win4.add(modalView);});出现错误:消息-'uncaughtsyntaxerror:uncontractedtoken{,Source-\u filename,\u dirname,tianium,Ti,global,kroll){module.exports=Modal(){。我对模块一无所知,所以我不知道您的错误是什么