我有一个正在创建 PopupWindow 的 View 。在这个 PopupWindow 中,我有一个文本框 (EditText)。单击编辑文本时,键盘打开,整个 View 上升,但 View 顶部平滑地在操作栏 View 下。到目前为止一切顺利。
我现在添加了一个空的GridView,没有对PopupWindow进行任何进一步的配置,现在发生了同样的情况,但是 View 的整个顶部都变成了在操作栏 View 的顶部 并且不平滑(弹出窗口变得一团糟,当键盘消失时,弹出窗口位置会更改几秒钟,并且键盘会出现“剩余”一秒钟)。 ListView 也会发生这种情况。
我希望 View 的顶部顺利地进入“ActionBar”下方,这是应该的。
有什么想法吗?
更新:通过以编程方式添加 GridView,我在一些设备上部分解决了它,但在某些设备上它仍然会发生。
显示弹出窗口:
pView=inflater.inflate(R.layout.activity_packbuild, (ViewGroup)mainActivity.findViewById(R.layout.activity_main));
pw = new PopupWindow(
pView,
ma.f.getView().getMeasuredWidth(),
ma.f.getView().getMeasuredHeight(),
true);
pw.showAtLocation(mainActivity.getWindow().getDecorView().findViewById(android.R.id.content), Gravity.BOTTOM, 0, 0);
好:
坏的:
布局:
<?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:id="@+id/lID">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/rID"
android:background="@drawable/back5">
<ImageView
android:layout_width="125px"
android:layout_height="200px"
android:id="@+id/mImageView"
android:background="@drawable/com_facebook_picker_default_separator_color"
android:layout_alignParentTop="true"
android:layout_weight="1"
android:layout_centerHorizontal="true"
android:layout_marginTop="300dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText"
android:layout_below="@+id/mImageView"
android:layout_marginTop="22dp"
android:layout_toRightOf="@+id/lButton"
android:layout_toLeftOf="@+id/rButton" />
<ImageView
android:layout_width="125px"
android:layout_height="200px"
android:id="@+id/imageViewRR"
android:background="@drawable/com_facebook_picker_default_separator_color"
android:layout_alignTop="@+id/mImageView"
android:layout_toRightOf="@+id/mImageView"
android:layout_marginLeft="20dp" />
<ImageView
android:layout_width="125px"
android:layout_height="200px"
android:id="@+id/imageViewLL"
android:background="@drawable/com_facebook_picker_default_separator_color"
android:layout_alignTop="@+id/mImageView"
android:layout_toLeftOf="@+id/mImageView"
android:layout_marginRight="20dp" />
<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/lButton"
android:layout_below="@+id/editText"
android:layout_alignLeft="@+id/imageViewLL"
android:layout_alignStart="@+id/imageViewLL" />
<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/rButton"
android:layout_alignTop="@+id/lButton"
android:layout_alignRight="@+id/imageViewRR"
android:layout_alignEnd="@+id/imageViewRR"
android:layout_marginTop="5dp" />
<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/picButton"
android:layout_alignTop="@+id/galleryButton"
android:layout_alignLeft="@+id/editText"
android:layout_alignStart="@+id/editText"
android:background="@drawable/camera2" />
<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/videoButton"
android:background="@drawable/video"
android:layout_alignTop="@+id/galleryButton"
android:layout_centerHorizontal="true" />
<ImageView
android:layout_width="125px"
android:layout_height="200px"
android:id="@+id/imageViewR"
android:background="@drawable/com_facebook_picker_default_separator_color"
android:layout_above="@+id/editText"
android:layout_alignRight="@+id/sendButon"
android:layout_alignEnd="@+id/sendButon" />
<ImageView
android:layout_width="125px"
android:layout_height="200px"
android:id="@+id/imageViewL"
android:background="@drawable/com_facebook_picker_default_separator_color"
android:layout_alignTop="@+id/mImageView"
android:layout_alignLeft="@+id/editText" />
<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/galleryButton"
android:background="@drawable/gallery"
android:layout_alignTop="@+id/rButton"
android:layout_alignRight="@+id/imageViewR" />
<ImageButton
android:layout_width="100px"
android:layout_height="100px"
android:id="@+id/toButton"
android:layout_above="@+id/imageViewR"
android:layout_alignLeft="@+id/picButton"
android:layout_alignStart="@+id/imageViewL"
android:background="@drawable/fbfriends2"
android:layout_alignRight="@+id/imageViewLL"
android:layout_alignEnd="@+id/imageViewLL"
android:layout_marginBottom="20dp" />
<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/sendButon"
android:background="@drawable/go"
android:layout_alignTop="@+id/toButton"
android:layout_alignRight="@+id/editText"
android:layout_alignEnd="@+id/editText" />
<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/plusButtonL"
android:background="@drawable/plusp"
android:layout_alignTop="@+id/videoButton"
android:layout_toRightOf="@+id/imageViewLL" />
<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/minusButtonR"
android:background="@drawable/minusp"
android:layout_alignTop="@+id/videoButton"
android:layout_toLeftOf="@+id/imageViewRR" />
<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/plusButton"
android:background="@drawable/plusp"
android:layout_alignTop="@+id/videoButton"
android:layout_centerHorizontal="true" />
<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/minusButton"
android:background="@drawable/minusp"
android:layout_alignTop="@+id/videoButton"
android:layout_centerHorizontal="true"
android:layout_marginTop="300dp" />
</RelativeLayout>
我正在以编程方式添加 GridView:
gv=new GridView(ma);
List<Student> hhh=new ArrayList<Student>();
if (FriendPickerApplication.selectedUsers!=null) {
if (FriendPickerApplication.selectedUsers.size() > 0) {
for (GraphUser gu : FriendPickerApplication.selectedUsers) {
hhh.add(new Student("name", gu.getId()));
}
}
}
StudentAdapter sta=new StudentAdapter(ma,hhh);
//gv=(GridView)pView.findViewById(R.id.gridView2);
gv.setVisibility(View.VISIBLE);
MainActivity.wantedPicSize=ma.screenWidth/12; //6
int wantedSize=MainActivity.wantedPicSize+2; //10
RelativeLayout.LayoutParams relativeParams = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.MATCH_PARENT);
relativeParams.addRule(RelativeLayout.LEFT_OF, btnSend.getId());
relativeParams.addRule(RelativeLayout.RIGHT_OF,picFriends.getId());
relativeParams.addRule(RelativeLayout.ALIGN_TOP, picFriends.getId());
relativeParams.addRule(RelativeLayout.ALIGN_BOTTOM, picFriends.getId());
gv.setLayoutParams(relativeParams);
gv.setPadding(5,0,5,0);
((RelativeLayout)pView.findViewById(R.id.rID)).addView(gv);
ViewGroup.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.FILL_PARENT,
RelativeLayout.LayoutParams.FILL_PARENT);//gv.getLayoutParams();
relativeParams.height = wantedSize+(int)(wantedSize/5); //this is in pixels
relativeParams.width = (int)(ma.screenWidth/3.0);//gv.getLayoutParams().width; //(int)( ( ((ma.screenWidth*3)/4)/wantedSize )*wantedSize );
gv.setColumnWidth(wantedSize); //+width betwen profiles
gv.setVerticalSpacing(5);
//gv.setNumColumns((int)((screenWidth/2)/100));
gv.setNumColumns((relativeParams.width/wantedSize));
System.out.print("COLUMNSSSSSSSSSS- "+(relativeParams.width/wantedSize));
gv.setLayoutParams(relativeParams);
gv.setVisibility(View.VISIBLE);
gv.setAdapter(sta);
最佳答案
这里的问题是弹出窗口。 没有办法让它进入操作栏下方,因为操作栏显示在您正在创建的新窗口下方的另一个窗口中。此外,为复杂的布局使用弹出窗口永远不会有效执行。您是否考虑过将您的 map 和放置在自定义布局中的弹出窗口中的布局包装起来?这可能是更简单的解决方案
关于Android-向布局添加 View 导致布局位于 ActionBar 前面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30004234/
当我使用Bundler时,是否需要在我的Gemfile中将其列为依赖项?毕竟,我的代码中有些地方需要它。例如,当我进行Bundler设置时:require"bundler/setup" 最佳答案 没有。您可以尝试,但首先您必须用鞋带将自己抬离地面。 关于ruby-我需要将Bundler本身添加到Gemfile中吗?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/4758609/
我需要从一个View访问多个模型。以前,我的links_controller仅用于提供以不同方式排序的链接资源。现在我想包括一个部分(我假设)显示按分数排序的顶级用户(@users=User.all.sort_by(&:score))我知道我可以将此代码插入每个链接操作并从View访问它,但这似乎不是“ruby方式”,我将需要在不久的将来访问更多模型。这可能会变得很脏,是否有针对这种情况的任何技术?注意事项:我认为我的应用程序正朝着单一格式和动态页面内容的方向发展,本质上是一个典型的网络应用程序。我知道before_filter但考虑到我希望应用程序进入的方向,这似乎很麻烦。最终从任何
我想要做的是有2个不同的Controller,client和test_client。客户端Controller已经构建,我想创建一个test_clientController,我可以使用它来玩弄客户端的UI并根据需要进行调整。我主要是想绕过我在客户端中内置的验证及其对加载数据的管理Controller的依赖。所以我希望test_clientController加载示例数据集,然后呈现客户端Controller的索引View,以便我可以调整客户端UI。就是这样。我在test_clients索引方法中试过这个:classTestClientdefindexrender:template=>
我有一个ModularSinatra应用程序,我正在尝试将Bootstrap添加到应用程序中。get'/bootstrap/application.css'doless:"bootstrap/bootstrap"end我在views/bootstrap中有所有less文件,包括bootstrap.less。我收到这个错误:Less::ParseErrorat/bootstrap/application.css'reset.less'wasn'tfound.Bootstrap.less的第一行是://CSSReset@import"reset.less";我尝试了所有不同的路径格式,但它
我正在使用Sequel构建一个愿望list系统。我有一个wishlists和itemstable和一个items_wishlists连接表(该名称是续集选择的名称)。items_wishlists表还有一个用于facebookid的额外列(因此我可以存储opengraph操作),这是一个NOTNULL列。我还有Wishlist和Item具有续集many_to_many关联的模型已建立。Wishlist类也有:selectmany_to_many关联的选项设置为select:[:items.*,:items_wishlists__facebook_action_id].有没有一种方法可以
我是一个Rails初学者,但我想从我的RailsView(html.haml文件)中查看Ruby变量的内容。我试图在ruby中打印出变量(认为它会在终端中出现),但没有得到任何结果。有什么建议吗?我知道Rails调试器,但更喜欢使用inspect来打印我的变量。 最佳答案 您可以在View中使用puts方法将信息输出到服务器控制台。您应该能够在View中的任何位置使用Haml执行以下操作:-puts@my_variable.inspect 关于ruby-on-rails-如何在我的R
我是rails的新手,想在form字段上应用验证。myviewsnew.html.erb.....模拟.rbclassSimulation{:in=>1..25,:message=>'Therowmustbebetween1and25'}end模拟Controller.rbclassSimulationsController我想检查模型类中row字段的整数范围,如果不在范围内则返回错误信息。我可以检查上面代码的范围,但无法返回错误消息提前致谢 最佳答案 关键是您使用的是模型表单,一种显示ActiveRecord模型实例属性的表单。c
当谈到运行时自省(introspection)和动态代码生成时,我认为ruby没有任何竞争对手,可能除了一些lisp方言。前几天,我正在做一些代码练习来探索ruby的动态功能,我开始想知道如何向现有对象添加方法。以下是我能想到的3种方法:obj=Object.new#addamethoddirectlydefobj.new_method...end#addamethodindirectlywiththesingletonclassclass这只是冰山一角,因为我还没有探索instance_eval、module_eval和define_method的各种组合。是否有在线/离线资
我注意到类定义,如果我打开classMyClass,并在不覆盖的情况下添加一些东西我仍然得到了之前定义的原始方法。添加的新语句扩充了现有语句。但是对于方法定义,我仍然想要与类定义相同的行为,但是当我打开defmy_method时似乎,def中的现有语句和end被覆盖了,我需要重写一遍。那么有什么方法可以使方法定义的行为与定义相同,类似于super,但不一定是子类? 最佳答案 我想您正在寻找alias_method:classAalias_method:old_func,:funcdeffuncold_func#similartoca
是否可以为特定(或所有)项目使用多个布局?例如,我有几个项目,我想对其应用两种不同的布局。一个是绿色的,一个是蓝色的(但是)。我想将它们编译到我的输出目录中的两个不同文件夹中(例如v1和v2)。我一直在玩弄规则和编译block,但我不知道这是怎么回事。因为,每个项目在编译过程中只编译一次,我不能告诉nanoc第一次用layout1编译,第二次用layout2编译。我试过这样的东西,但它导致输出文件损坏。compile'*'doifitem.binary?#don’tfilterbinaryitemselsefilter:erblayout'layout1'layout'layout2'