DialogFragment FEATURE_NO_TITLE 缩小了 [英] DialogFragment FEATURE_NO_TITLE is shrunk

查看:35
本文介绍了DialogFragment FEATURE_NO_TITLE 缩小了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在显示一个 DialogFragment.我毫无问题地实现了它,直到我决定使用 getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); 删除标题.这样做之后,整个事情都会缩小.这是我的 xml 和类文件.

I'm displaying a DialogFragment. I implemented it with no problems, until I decided to remove the title using getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);.After doing that the whole thing shrinks. Here are my xml and class files.

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:background="@color/white"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="@dimen/activity_vertical_margin">

    <TextView
        android:id="@+id/product_name"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="@color/red"
        android:textSize="20sp"
        android:text="@string/client_name_hint"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="100"
        android:layout_marginTop="@dimen/activity_vertical_margin"
        android:layout_marginBottom="@dimen/activity_vertical_margin"
        android:orientation="horizontal">

        <ImageView
            android:id="@+id/product_image"
            android:layout_width="0dp"
            android:layout_weight="50"
            android:layout_height="match_parent"/>

        <LinearLayout
            android:layout_width="0dp"
            android:layout_weight="50"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <TextView
                android:id="@+id/product_price"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:gravity="center_vertical"
                android:textColor="@color/red"
                android:textSize="30sp"
                android:textStyle="bold"
                android:text="$349.00"/>

            <TextView
                android:id="@+id/product_color"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textStyle="bold"
                android:textSize="20sp"
                android:text="Color: White"/>

        </LinearLayout>

    </LinearLayout>

    <TextView
        android:id="@+id/product_description"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="@dimen/activity_vertical_margin"
        android:background="#aaada9"
        android:text="Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:clickable="true"
        android:layout_marginTop="@dimen/activity_vertical_margin"
        android:layout_gravity="right"
        android:gravity="center_vertical"
        android:drawableRight="@android:drawable/ic_input_add"
        android:textColor="@color/red"
        android:text="@string/buy"/>

</LinearLayout>




public class ProductsDetailFragment extends DialogFragment {

    public static final String TAG = "products_detail";

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

我错过了什么?

推荐答案

在你的 onCreate() 中设置样式,这有助于我没有缩小没有标题的对话框.

Set style in your onCreate(), this helps me to have not shrunk dialog without title.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setStyle(DialogFragment.STYLE_NO_TITLE, android.R.style.Theme_Holo_Light_Dialog_NoActionBar_MinWidth);
}

这篇关于DialogFragment FEATURE_NO_TITLE 缩小了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆