相关疑难解决方法(0)

Android中的全屏DialogFragment

我正在尝试显示几乎全屏的DialogFragment.但我不知道怎么做不到.

我展示Fragment的方式直接来自android开发者文档

FragmentManager f = ((Activity)getContext()).getFragmentManager();
FragmentTransaction ft = f.beginTransaction();
Fragment prev = f.findFragmentByTag("dialog");
if (prev != null) {
    ft.remove(prev);
}
ft.addToBackStack(null);

// Create and show the dialog.
DialogFragment newFragment = new DetailsDialogFragment();
newFragment.show(ft, "dialog");
Run Code Online (Sandbox Code Playgroud)

我知道天真地尝试将片段中的RelativeLayout设置为fill_parent和一些minWidth和minHeight.

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"  
    android:minWidth="1000px" 
    android:minHeight="600px"
    android:background="#ff0000">
Run Code Online (Sandbox Code Playgroud)

我知道期望DialogFragment填满屏幕的大部分.但我似乎只是垂直调整大小,但只是水平固定宽度.

我还尝试在代码中设置窗口属性,如下所示:http://groups.google.com/group/android-developers/browse_thread/thread/f0bb813f643604ec.但这也没有帮助.

我可能误解了Android处理Dialogs的方式,因为我对它不熟悉.我怎么能这样做?有没有其他方法可以实现我的目标?


Android设备:
华硕EeePad Transformer
Android 3.0.1


更新: 我现在设法将其全屏显示,片段中包含以下代码

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setStyle(STYLE_NO_FRAME, android.R.style.Theme_Holo_Light);
}
Run Code Online (Sandbox Code Playgroud)

不幸的是,这不是我想要的.我肯定需要在对话框周围显示一个小"填充"来显示背景.

任何想法如何实现?

android android-dialogfragment

148
推荐指数
13
解决办法
13万
查看次数

全屏DialogFragment

我试图创建MATCH_PARENT宽度的DialogFragment这样的对话框几乎全屏幕(离开填充周围的边缘为流动的样子).我在Android中看到过这个解决方案Full Screen DialogFragment,但我试图避免将宽度设置为1000dp的黑客攻击.以我目前的布局,我是使用FILL_PARENT或MATCH_PARENT它似乎是设置宽度和高度WRAP_CONTENT.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
Run Code Online (Sandbox Code Playgroud)

我已经将此解决方案用于Dialog(而不是DialogFragment),它按预期工作:

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Run Code Online (Sandbox Code Playgroud)

android android-dialogfragment

20
推荐指数
3
解决办法
3万
查看次数

Android对话 - 圆角和透明度

我正在尝试使用圆角制作自定义的android对话框.我目前的尝试给了我这个结果.

圆角对话框

正如您所看到的,角落是圆的,但它仍然保持完整的白色角落.

下面是我放在drawable文件夹中的xml,用于创建带有圆角的红色边框的蓝色对话框.

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item> 
        <shape 
            android:shape="rectangle">
            <solid android:color="@color/transparent_black" />
            <corners android:radius="@dimen/border_radius"/>
        </shape>
    </item>   
    <item 
        android:left="@dimen/border_width" 
        android:right="@dimen/border_width"  
        android:top="@dimen/border_width"
        android:bottom="@dimen/border_width" >  

        <shape android:shape="rectangle"> 
            <solid android:color="@color/blue" />
            <corners android:radius="@dimen/border_radius"/>
        </shape>
    </item>    
</layer-list>
Run Code Online (Sandbox Code Playgroud)

下面是对话框的布局.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/fill"
android:orientation="vertical"
android:layout_margin="@dimen/spacing_normal"
android:padding="@dimen/spacing_normal"

android:background="@drawable/border_error_dialog" >

<RelativeLayout 
    style="@style/block"
    android:layout_gravity="center" >

    <ImageView
        android:id="@+id/imageView1"
        style="@style/wrap"
        android:layout_alignParentLeft="true"
        android:layout_centerHorizontal="true"
        android:contentDescription="@string/content_description_filler"
        android:src="@drawable/ic_launcher" />

    <TextView
        android:id="@+id/textView1"
        style="@style/error_text"
        android:layout_centerVertical="true"
        android:layout_toRightOf="@+id/imageView1"
        android:text="@string/error_login" />

</RelativeLayout>

<Button
    android:id="@+id/button1"
    style="@style/wrap"
    android:layout_gravity="center"
    android:text="Button" />

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

以下是我创建对话框的Activity.

@Override
protected void onCreate(Bundle savedInstanceState) { …
Run Code Online (Sandbox Code Playgroud)

android dialog transparent android-layout android-alertdialog

20
推荐指数
4
解决办法
3万
查看次数

如何创建100%自定义DialogFragment

我希望使用完全自定义的片段的Android对话框:不包括任何平台对话框主题片段.例如,像这样:

屏幕截图

我该怎么做呢?

android xamarin.android

13
推荐指数
2
解决办法
2万
查看次数