相关疑难解决方法(0)

透明AlertDialog有黑色背景

我有一个自定义AlertDialog样式,使AlertDialog框透明.它工作正常,除了当我将所需的透明布局膨胀到警报对话框窗口时,它显示为黑色背景.我的目标是AlertDialog让它看起来完全透明,好像只有4个按钮浮动而不是框架.图像一是自定义对话框给我的,图像二是我想要的或我的目标.

这是自定义的代码 Dialog

<style name="CustomDialog" parent="android:Theme.Dialog">
    <item name="android:windowFrame">@null</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowIsFloating">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowTitleStyle">@null</item>
    <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
    <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
    <item name="android:backgroundDimEnabled">false</item>
    <item name="android:background">@android:color/transparent</item>
</style>
Run Code Online (Sandbox Code Playgroud)

这就是我在我的呼唤 onCreate()

AlertDialog.Builder imageDialog = new AlertDialog.Builder(TimeLine.this, R.style.CustomDialog);
inflater = getLayoutInflater();
View view=inflater.inflate(R.layout.tabs, null);![enter image description here][1]
AlertDialog a = imageDialog.create();
a.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
a.setView(view, 0, 0, 0, 0);

a.show();
Run Code Online (Sandbox Code Playgroud)

当前警报对话框

期望的AlertDialog

*编辑******选项卡布局xml的代码在这里 `

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:id="@+id/tabLayout"
    android:background="#000000ff">

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="New Button"
        android:id="@+id/button2"
        android:layout_marginTop="206dp"
        android:layout_below="@+id/button4"
        android:layout_alignStart="@+id/button4" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" …
Run Code Online (Sandbox Code Playgroud)

android android-alertdialog

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

如何以编程方式将活动主题化为对话框?

如何以编程方式(不触摸AndroidManifext.xml)设置主题Activity ,使其看起来像一个对话框

注意:我可以修改它AndroidManifext.xml,只要它不需要修改就可以在看起来像普通活动或对话框之间切换.

到目前为止我尝试过的

我根据这个stackoverflow答案尝试了以下内容:

public class DialogActivity extends Activity
{

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        setTheme(android.R.style.Theme_DeviceDefault_Dialog);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dialog);
        Log.d(TAG,"Build.VERSION.SDK_INT: "+Build.VERSION.SDK_INT); // 23
    }
}
Run Code Online (Sandbox Code Playgroud)

但它最终会在背景中消除掉一切.

我也看到了这个stackoverflow的答案,并试过:

public class DialogActivity extends Activity
{

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        setTheme(android.R.style.Theme_DeviceDefault_Dialog);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dialog);
        getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    }
}
Run Code Online (Sandbox Code Playgroud)

但它最终使一切变黑.

做什么?谢谢.

java android android-dialog android-activity

9
推荐指数
1
解决办法
6095
查看次数

如何删除自定义对话框的矩形框

我定制了一个对话框:

public class CustomizeDialog extends Dialog implements OnClickListener {
Button close;
TextView tv;
public CustomizeDialog(Context context,String Stringcontent) {
    super(context);
    requestWindowFeature(Window.FEATURE_NO_TITLE);      
    setContentView(R.layout.custom_diolog_main);
    tv=(TextView) findViewById(R.id.content);
    tv.setText(Stringcontent);
    close = (Button) findViewById(R.id.close);
    close.setOnClickListener(this);
}

@Override
public void onClick(View v) {       
    if (v == close)
        dismiss();
}

 }
Run Code Online (Sandbox Code Playgroud)

xml是

   <?xml version="1.0" encoding="utf-8"?>
  <RelativeLayout  
   xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_height="100dip" 
android:orientation="vertical"
android:background="@drawable/custom_diolog_bg"
android:layout_width="250dip">
<TextView android:layout_height="wrap_content"
    android:textColor="#000" 
    android:textStyle="bold" 
    android:textSize="18sp"
    android:id="@+id/content"
    android:layout_marginLeft="15dip"
    android:layout_marginTop="5dip"
    android:layout_alignParentTop="true"
    android:layout_width="250dip" 
    android:text=" Custom Dialog "/>


<Button android:layout_width="70dip"  
    android:layout_marginLeft="80dip"
    android:background="@drawable/custom_dialog_button_bg"
    android:layout_alignParentBottom="true"
    android:layout_height="40dip" android:text="??"   
        android:id="@+id/close"></Button>
 </RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

我的对话框很好,但custom_diolog_bg是一个圆角矩形图像,当我显示我的对话框时,它显示一个系统框架隐藏我的自定义,所以我使用this.getwindow.setBackgroundDrawable(null),然后系统框架似乎已删除但只有四角没有删除,我们也看到黑暗的四角,因为我使用圆角矩形图像.所以我的问题如何删除所有框架,以便我的对话看起来很好

图片是 http://i.stack.imgur.com/EG7oz.jpg,所以你可以看到最后有黑框,如何删除它?谢谢

android dialog

5
推荐指数
3
解决办法
8081
查看次数