我正在尝试通过这种方式以编程方式设置工具栏的高度:
toolbar.setLayoutParams(new Toolbar.LayoutParams(LayoutParams.MATCH_PARENT, 42));
toolbar.setMinimumHeight(42);
但它会导致此日志-> android.widget.relativelayout$layoutparams cannot be cast to android.support.v7.Toolbar$layoutparams出现致命异常
我也尝试了这个变体:
RelativeLayout.LayoutParams pa
我正在开发一个Android应用程序。我的应用程序将包括底部导航栏与四个项目和工具栏与一个项目。在我的项目中,当没有代码时,片段和应用程序都在工作,但是当我写了一行代码,比如"EditText editText=getView().findViewById(R.id.editText);“to a fragment java file,EditText to a fragment java file,我的应用程序在点击该片段后关闭。删除代码行后,我的应用程序工作正常。你能帮我一下吗?
我正在使用RelativeLayout创建一个简单的工具栏
和我正在使用以下代码的按钮图像,
ImageButton back = new ImageButton(ctx.getContext());
RelativeLayout.LayoutParams backLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
backLayoutParams.addRule(Relative