【发布时间】:2015-02-11 09:58:18
【问题描述】:
我正在 android 上编写一个自定义对话框。 我使用 onCreateView 方法做到了这一点。
public class CheckpointLongPressDialog extends DialogFragment {
public void CheckpointLongPressDialog() {}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_checkpoint_long_press_dialog, container);
getDialog().setTitle("TITLE");
return view;
}
如何以编程方式使标题居中?
【问题讨论】:
-
当您可以简单地更改
fragment_checkpoint_long_press_dialogxml 文件时,为什么要通过编程方式来给自己带来压力? -
@DerGolem 你是对的,但我认为有一种简单的方法可以以编程方式完成此操作
-
在 xml(1 行 代码)中做到这一点更简单。