如何创建无标题DialogFragment?
来源:互联网 发布:教务软件 编辑:程序博客网 时间:2024/05/16 16:18
我创建一个以示对我的应用程序.a切正常,除了一件事......有黑色条纹在窗口的顶部,显示了我是保留给冠军,我不想 这是特别痛苦的,因为我的自定义使用白色背景,这样的变化太被抛在一边。 给你看看这个更图形化的方式: 现在是我的XML代码如下:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:id="@+id/holding" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/dialog_fragment_bg" > <!-- Usamos un LinearLayout para que la imagen y el texto esten bien alineados --> <LinearLayout android:id="@+id/confirmationToast" android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content" > <TextView android:id="@+id/confirmationToastText" android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="@string/help_dialog_fragment" android:textColor="#AE0000" android:gravity="center_vertical" /> </LinearLayout> <LinearLayout android:id="@+id/confirmationButtonLL" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center_horizontal" > <Button android:id="@+id/confirmationDialogButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:layout_marginBottom="60dp" android:background="@drawable/ok_button"> </Button> </LinearLayout> </LinearLayout></ScrollView>
编辑:包括类的代码的public class HelpDialog extends DialogFragment {public HelpDialog(){ // Empty constructor required for DialogFragment}@Overridepublic View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { //Inflate the XML view for the help dialog fragment View view = inflater.inflate(R.layout.help_dialog_fragment, container); TextView text = (TextView)view.findViewById(R.id.confirmationToastText); text.setText(Html.fromHtml(getString(R.string.help_dialog_fragment))); //get the OK button and add a Listener ((Button) view.findViewById(R.id.confirmationDialogButton)).setOnClickListener(new OnClickListener() { public void onClick(View v) { // When button is clicked, call up to owning activity. HelpDialog.this.dismiss(); } }); return view;}
} 并在主要活动的创建过程:/** * Shows the HelpDialog Fragment */private void showHelpDialog() { android.support.v4.app.FragmentManager fm = getSupportFragmentManager(); HelpDialog helpDialog = new HelpDialog(); helpDialog.show(fm, "fragment_help");}
我真的不知道这个答案,有对话有关,适合在这里也android:如何创建一个对话框没有标题? 我怎样才能摆脱这个称号领域?本文地址 :CodeGo.net/8212383/ -------------------------------------------------------------------------------------------------------------------------1.只需添加这行代码在你的HelpDialog.onCreateView(...)
这样,你明确地要求得到一个窗口而不标题:) 编辑 由于getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
@DataGraham
和@Blundell
指出在下面,这是比较安全的补充要求在标题无窗onCreateDialog()
方法,而不是onCreateView()
。这样可以防止ennoying北角,当你你的Dialog
:@Overridepublic Dialog onCreateDialog(Bundle savedInstanceState) { Dialog dialog = super.onCreateDialog(savedInstanceState); // request a window without the title dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE); return dialog;}
对话框中有哪些应该在视图创建的Java文件被调用。还对话框的样式可以与设置public static MyDialogFragment newInstance() { MyDialogFragment mDialogFragment = new MyDialogFragment(); //Set Arguments here if needed for dialog auto recreation on screen rotation mDialogFragment.setStyle(DialogFragment.STYLE_NO_TITLE, 0); return mDialogFragment;}
2.设置样式为@Overridepublic void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setStyle(STYLE_NORMAL, android.R.style.Theme_Holo_Dialog_NoActionBar);}
3.FragmentManager manager = getSupportFragmentManager();SettingsDialog sd = new SettingsDialog();sd.setStyle(DialogFragment.STYLE_NO_TITLE, 0);sd.show(manager, "settings_dialog");
0 0
- 如何创建无标题DialogFragment?
- 如何使用DialogFragment类来创建和显示对话框
- 如何使用DialogFragment类来创建和显示对话框
- 如何拖动无标题窗体
- 无标题窗口如何移动
- DialogFragment创建对话框
- DialogFragment 创建对话框
- DialogFragment 创建对话框
- DialogFragment 创建对话框
- DialogFragment 创建对话框
- DialogFragment 创建对话框
- DialogFragment 创建对话框
- DialogFragment 创建对话框
- DialogFragment 创建对话框
- DialogFragment---官方推荐 : DialogFragment创建对话框
- 如何去掉MFC的无标题
- 继承AppCompatActivity如何实现无标题
- Android使用DialogFragment创建对话框
- Java中的自动类型转换
- WPF部署(一):WebService配置文件及编译时拷贝
- leetCode练习(61)
- 在Gazebo中使用DEM構建起伏地形環境
- SELECT INTO 和 INSERT INTO SELECT 两种表复制语句的不同
- 如何创建无标题DialogFragment?
- iOS UILabel高度自适应终结篇
- 卷积神经网络(CNN)在句子建模上的应用
- 图片验证码系统设计
- Spring Security学习笔记之SessionManagementFilter
- 【gulp】Refusing to install xxx as a dependency of itself
- CSS3新增样式大解析:[6]rotate之旋转-初级
- intelliJ IDEA maven配置
- CSS3 REM单位简说