我想在我的DialogFragment中自定义我的标题,我知道如何将标题设置为我的DialogFragment,但我想要的不仅仅是标题,还需要一个自定义标题(color,fontSize ...),所以我定义了一个TextView和定制它如何在DialogFragment中自定义标题
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.height_fragment,container,false);
TextView title = new TextView(getContext());
title.setText("Your Height Information");
title.setGravity(Gravity.CENTER);
title.setTextSize(30);
title.setBackgroundColor(Color.GRAY);
title.setTextColor(Color.WHITE);
getDialog().setCustomTitle(title); //Error Can not resolve method setCustomTitle(android.widget.TextView)
return view;
}
但在这一行
getDialog().setCustomTitle(title);
getDialog()错误setCustomTitle(职称)。
在发布这个问题之前,我搜索了很多,但我找不到我如何自定义我的DialogFragment标题。 感谢您花时间帮助我
您需要从您的布局引用的TextView。我会在一秒后发布一些代码 – bradkratky
您是否尝试过这种解决方案? (http://stackoverflow.com/questions/28977576/dialogfragment-with-a-custom-title) –
该方法是getDialog()。setTitle(String title)。 http://stackoverflow.com/questions/5193722/how-to-set-the-title-of-dialogfragment在谷歌上的第一个答案。 –