我搜索了所有关于 SO 的相关问题,基本上尝试了他们所有的解决方案,但没有任何进展。我想使用 BottomSheetDialogFragment 创建一个包含一些 EditText 和其他组件的底部表单模式对话框,这很容易。
我遇到的问题是软键盘覆盖了对话框的一半。我更改的任何设置似乎都不会在任何方面产生任何差异。 API 有什么变化吗?谷歌搜索似乎没有找到解决方案。当前发生的情况:键盘不覆盖当前选定的编辑文本,但覆盖其下方的对话框。我希望整个对话框始终可见并在键盘打开时移动。
这是我的 fragment 类:
public class GoalUpdateFormDialogFragment extends BottomSheetDialogFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.goal_update_form, container, false);
assert getDialog().getWindow() != null;
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
return view;
}
}
这是我正在使用的对话框布局文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/goal_update_bottom_sheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="5dp"
xmlns:android="http://schemas.android.com/apk/res/android"
app:layout_behavior="@string/bottom_sheet_behavior"
xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_margin="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/progress_update_hint"/>
<EditText
android:id="@+id/goal_progress_number_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/goal_progress_box_hint"
android:inputType="number"/>
</LinearLayout>
<EditText
android:id="@+id/goal_update_comment_box"
style="@style/Widget.AppCompat.EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top"
android:hint="@string/comment"
android:lines="4"
android:maxLines="6"
android:inputType="textMultiLine"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/image_attachment_file_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/image_file_name_placeholder"
android:layout_marginStart="10dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"/>
<ImageButton
android:id="@+id/delete_attachment_button"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginStart="4dp"
android:layout_gravity="center_vertical"
android:background="@drawable/transparent"
android:alpha="0.54"
android:src="@drawable/ic_delete_black_24dp"/>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start">
<ImageButton
android:id="@+id/attach_file_button"
android:layout_width="32dp"
android:layout_height="32dp"
android:background="@drawable/transparent"
android:src="@drawable/ic_attach_file_black_24dp"
android:alpha="0.54"/>
<ImageButton
android:id="@+id/attach_image_button"
android:layout_width="32dp"
android:layout_height="32dp"
android:background="@drawable/transparent"
android:layout_toEndOf="@id/attach_file_button"
android:src="@drawable/ic_add_a_photo_black_24dp"
android:alpha="0.54"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/max_one_attachment"
android:layout_toEndOf="@id/attach_image_button"
android:layout_centerVertical="true"
android:layout_marginStart="10dp"
android:alpha="0.5"/>
<ImageButton
android:id="@+id/submit_button"
android:layout_width="32dp"
android:layout_height="32dp"
android:src="@drawable/ic_send_black_24dp"
android:background="@drawable/transparent"
android:layout_alignParentEnd="true"
android:alpha="0.54"/>
</RelativeLayout>
</LinearLayout>
下面是显示对话框的 Activity 布局:
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.iepone.classroom.view.activities.StudentDetailActivity"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/todo"
android:layout_gravity="center"
android:textAlignment="center"/>
<Button
android:id="@+id/pick_image_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pick image"
android:onClick="onClickPickImage"/>
<Button
android:id="@+id/test_comment_box_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test comment box"
android:onClick="onClickTestCommentBox"/>
<ImageView
android:id="@+id/test_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
编辑:根据请求,这里是 android list ,删除了不相关的位:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="REDACTED">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:replace="android:label">
<activity
android:name=".view.activities.SplashActivity"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".view.activities.MainActivity"
android:theme="@style/MainActivityTheme" />
<activity
android:name=".view.activities.StudentDetailActivity"/>
</application>
</manifest>
最佳答案
如果 bottomsheet 上的 ui 非常大,最好使用固定大小的 NestedScrollView;
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="500dp"
android:background="@color/colorWhite"
android:orientation="vertical">
......Other views
</android.support.v4.widget.NestedScrollView>
还有一个 BottomSheetBehavior,就像在您的 bottomSheet 中一样;
定义一个成员变量
private BottomSheetBehavior.BottomSheetCallback mBottomSheetBehaviorCallback = new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
if (newState == BottomSheetBehavior.STATE_HIDDEN) {
dismiss();
}
}
@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
}
};
然后设置
@Override
public void setupDialog(Dialog dialog, int style) {
super.setupDialog(dialog, style);
View contentView = View.inflate(getContext(), R.layout.content_register, null);
ButterKnife.bind(this, contentView);
dialog.setContentView(contentView);
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) ((View) contentView.getParent()).getLayoutParams();
CoordinatorLayout.Behavior behavior = params.getBehavior();
if( behavior != null && behavior instanceof BottomSheetBehavior ) {
((BottomSheetBehavior) behavior).setBottomSheetCallback(mBottomSheetBehaviorCallback);
((BottomSheetBehavior) behavior).setState(BottomSheetBehavior.STATE_EXPANDED);
}
}
关于java - 软键盘覆盖底部工作表对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48966333/
我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-
我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t
我有一个包含模块的模型。我想在模块中覆盖模型的访问器方法。例如:classBlah这显然行不通。有什么想法可以实现吗? 最佳答案 您的代码看起来是正确的。我们正在毫无困难地使用这个确切的模式。如果我没记错的话,Rails使用#method_missing作为属性setter,因此您的模块将优先,阻止ActiveRecord的setter。如果您正在使用ActiveSupport::Concern(参见thisblogpost),那么您的实例方法需要进入一个特殊的模块:classBlah
我花了三天的时间用头撞墙,试图弄清楚为什么简单的“rake”不能通过我的规范文件。如果您遇到这种情况:任何文件夹路径中都不要有空格!。严重地。事实上,从现在开始,您命名的任何内容都没有空格。这是我的控制台输出:(在/Users/*****/Desktop/LearningRuby/learn_ruby)$rake/Users/*******/Desktop/LearningRuby/learn_ruby/00_hello/hello_spec.rb:116:in`require':cannotloadsuchfile--hello(LoadError) 最佳
我真的很习惯使用Ruby编写以下代码:my_hash={}my_hash['test']=1Java中对应的数据结构是什么? 最佳答案 HashMapmap=newHashMap();map.put("test",1);我假设? 关于java-等价于Java中的RubyHash,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/22737685/
关闭。这个问题需要detailsorclarity.它目前不接受答案。想改进这个问题吗?通过editingthispost添加细节并澄清问题.关闭8年前。Improvethisquestion在首页我有:汽车:VolvoSaabMercedesAudistatic_pages_spec.rb中的测试代码:it"shouldhavetherightselect"dovisithome_pathit{shouldhave_select('cars',:options=>['volvo','saab','mercedes','audi'])}end响应是rspec./spec/request
在Rails4.0.2中,我使用s3_direct_upload和aws-sdkgems直接为s3存储桶上传文件。在开发环境中它工作正常,但在生产环境中它会抛出如下错误,ActionView::Template::Error(noimplicitconversionofnilintoString)在View中,create_cv_url,:id=>"s3_uploader",:key=>"cv_uploads/{unique_id}/${filename}",:key_starts_with=>"cv_uploads/",:callback_param=>"cv[direct_uplo
我在pry中定义了一个函数:to_s,但我无法调用它。这个方法去哪里了,怎么调用?pry(main)>defto_spry(main)*'hello'pry(main)*endpry(main)>to_s=>"main"我的ruby版本是2.1.2看了一些答案和搜索后,我认为我得到了正确的答案:这个方法用在什么地方?在irb或pry中定义方法时,会转到Object.instance_methods[1]pry(main)>defto_s[1]pry(main)*'hello'[1]pry(main)*end=>:to_s[2]pry(main)>defhello[2]pry(main)
我正在尝试在Ruby中制作一个cli应用程序,它接受一个给定的数组,然后将其显示为一个列表,我可以使用箭头键浏览它。我觉得我已经在Ruby中看到一个库已经这样做了,但我记不起它的名字了。我正在尝试对soundcloud2000中的代码进行逆向工程做类似的事情,但他的代码与SoundcloudAPI的使用紧密耦合。我知道cursesgem,我正在考虑更抽象的东西。广告有没有人见过可以做到这一点的库或一些概念证明的Ruby代码可以做到这一点? 最佳答案 我不知道这是否是您正在寻找的,但也许您可以使用我的想法。由于我没有关于您要完成的工作
在Ruby类中,我重写了三个方法,并且在每个方法中,我基本上做同样的事情:classExampleClassdefconfirmation_required?is_allowed&&superenddefpostpone_email_change?is_allowed&&superenddefreconfirmation_required?is_allowed&&superendend有更简洁的语法吗?如何缩短代码? 最佳答案 如何使用别名?classExampleClassdefconfirmation_required?is_a