android加载自定义dialog,背景总是黑色的。不知道为什么。求解答

java代码:

LayoutInflater inflater = LayoutInflater.from(getActivity());
View v1 = inflater.inflate(R.layout.progress_dialog_item, null);// 得到加载view
RelativeLayout layout = (RelativeLayout) v1.findViewById(R.id.dialog_view);// 加载布局

AsAlertDialog.Builder builder = new AsAlertDialog.Builder(getActivity());
progressDialog = builder.create();

progressDialog.show();
progressDialog.setContentView(layout,new RelativeLayout.LayoutParams(

RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT));

————————————————————————————————
xml:
<?xml version="1.0" encoding="utf-8"?>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00000000"
android:id="@+id/dialog_view" >

<RelativeLayout
    android:id="@+id/progress_layout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:background="#00000000" >

    <ProgressBar
        android:id="@+id/process_bar"
        style="?android:attr/progressBarStyle"
        android:layout_width="50px"
        android:layout_height="50px"
        android:layout_centerVertical="true"
        android:indeterminateBehavior="repeat"
        android:indeterminateDrawable="@drawable/loading_process"
        android:indeterminateDuration="500"
        android:indeterminateOnly="true"
        android:background="#00000000"
        android:interpolator="@android:anim/linear_interpolator" />

    <TextView
        android:id="@+id/progress_textview"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_marginLeft="10px"
        android:layout_toRightOf="@id/process_bar"
        android:gravity="center_vertical"
        android:text="@string/weather_waiting"
        android:textColor="#FFFFFF"
        android:background="#00000000"
        android:textSize="24px" />
</RelativeLayout>

查看全部
lixuesong13
devin_lxs
2015/08/15 07:58
  • dialog
  • android
  • 点赞
  • 收藏
  • 回答
    私信

3个回复