Erstellen von Android-Transparent-Layout in den Benutzerdefinierten Alert-Dialog
Ich geschrieben habe, ein eigenes Dialogfeld, das funktioniert bestens.
public class GalleryAlertDialog extends Dialog {}
In der einen Klasse rufe ich die Klasse mit der
dialog.show();
Ich will, um dies zu erreichen suchen:
Brauche ich die Schaltfläche über den dialog,wie diesem.
Dies ist jedoch, was ich bekomme:
Hier ist der layout xml ' s Teil wo ich erkläre das layout und die Schaltfläche innen:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/llContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="vertical">
<LinearLayout
android:id="@+id/ll_buttonContainer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginBottom="5dip"
android:gravity="right"
android:orientation="vertical" >
<ImageButton
android:id="@+id/btn_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/selector_button_popupclose"
android:contentDescription="TODO"
android:tag="btn_close" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll_pagerContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/ll_buttonContainer"
android:layout_marginTop="80dip"
android:background="@color/white" />
<ToggleButton
android:id="@+id/tbFavorite"
android:layout_width="35dip"
android:layout_height="35dip"
android:layout_gravity="bottom|right"
android:layout_marginBottom="10dp"
android:layout_marginRight="10dip"
android:background="@drawable/selector_check"
android:checked="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:textOff=""
android:textOn="" />
</FrameLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#ff212121"
android:gravity="center_vertical"
android:orientation="horizontal" >
<LinearLayout
android:id="@+id/llContactFullName"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@color/white"
android:gravity="left|center_vertical"
android:orientation="vertical" >
<View
android:layout_width="fill_parent"
android:layout_height="5dp"
android:background="@color/seperator" />
<TextView
android:id="@+id/txtContactFullName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:ellipsize="end"
android:maxLines="1"
android:paddingRight="5dp"
android:singleLine="true"
android:textColor="@color/black"
android:textSize="20sp" />
<TextView
android:id="@+id/txtTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:ellipsize="end"
android:maxLines="1"
android:paddingRight="5dp"
android:singleLine="true"
android:textColor="@color/black"
android:textSize="14sp" />
<TextView
android:id="@+id/txtCompany"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginTop="10dip"
android:ellipsize="end"
android:maxLines="1"
android:paddingRight="5dp"
android:singleLine="true"
android:textColor="@color/black"
android:textSize="14sp" />
<TextView
android:id="@+id/txtPosition"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dip"
android:layout_marginLeft="10dip"
android:ellipsize="end"
android:maxLines="1"
android:paddingRight="5dp"
android:singleLine="true"
android:textColor="@color/black"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
.....
Ich habe versucht, die ll_buttonContainer einen transparenten hintergrund programmatisch zu.
llButtonContainer.setBackgroundColor(mContext.getResources().getColor(
R.color.transparent_tr));
llButtonContainer.setBackgroundColor(Color.argb(0, 0, 0, 0));
Ich habe sogar versucht
android:background="null"
Nichts funktioniert. Das layout ist noch sichtbar, es wird jede Farbe (rot, gelb, weiß etc.) andere als transparent. Ist dies, wie es funktioniert, werde ich nicht in der Lage sein zu geben, es transparente hintergrund durch, wie Dialog funktioniert?
Vielen Dank für jede Hilfe.
- Zeigen Sie uns Ihre ganze xml-bitte, das problem kann in der übergeordneten LinearLayout
Du musst angemeldet sein, um einen Kommentar abzugeben.
Ok, ich fand die Antwort selbst.
Fand ich diese Zeile auf StackOverFlow, habe es ausprobiert und es funktionierte.
Schreiben Sie diese Zeile,
kurz vor
Hoffe das hilft einigen ein und Sie nicht so viel leiden wie ich. Es ist ziemlich einfach, aber sehr ärgerlich, wenn Sie es vermissen.
Verwenden Sie diesen Stil in Ihrem res/values/style
machen WindowTranparent
Wenden Sie diese, um Ihren Dialog...