Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fragment Dialog without Title issue

Tags:

java

android

i'm trying to create a fragment dialog and need the full space to display information. so i want to disable the titlebar. But after i disabled it the isn't maximized in width anymore.

public class ArticleSearchFragment extends DialogFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setStyle(STYLE_NO_TITLE, getTheme());
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  View view = inflater.inflate(R.layout.article_search, container, false);
  ...
}

And the XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<AutoCompleteTextView
    android:id="@+id/searchField"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10"
    android:hint="Ean / Name / Produkt Nummer"
    android:completionThreshold="1" />
<Button
   android:id="@+id/cancel"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:text="@string/cancel" />

</LinearLayout>
like image 598
Kani Avatar asked Dec 03 '12 14:12

Kani


1 Answers

put this code in your onCreateView() of dialog fragment

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_view_image, null);
   getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
   return view;
}

It will remove title bar from Dialog Fragment

like image 79
Gru Avatar answered Sep 25 '22 10:09

Gru