我正在用希伯来语(即 rtl)编写一个应用程序。 当我为对话框 fragment 设置标题时,它出现在左侧。 我试图通过以下方式使其显示在右侧:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
//set's up the title for this dialog fragment
getDialog().getWindow().setGravity(Gravity.RIGHT);
getDialog().setTitle(R.string.find_Address_text);
但不影响标题的位置。 我怎样才能做到这一点? TNX
最佳答案
隐藏默认标题并在布局中制作自定义标题。
隐藏默认标题:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStyle(STYLE_NO_TITLE, 0); // remove title from dialogfragment
}
然后使用您喜欢的样式将 TextView 添加到布局的顶部:
<TextView
android:id="@+id/dialog_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right|center"
android:text="@string/dialog_title" />
关于android - 将对话框 fragment 标题设置为从右侧显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10470238/