2014-04-06 4 views
0

다른 스타일로 맞춤 알림 대화 상자를 만들고 싶습니다. 우리가 알다시피, 기본 스타일은 사각형입니다. 나는 너가 이제까지 본 경우에 그것을 사탕 찌그러 뜨림 게임에 좋아하게하고 싶다. 배경 스타일을 변경하려고 시도했지만 기본 배경이 계속 표시됩니다. 내 대화 상자 레이아웃을위한 내 xml 파일입니다.Android에서 맞춤 알림 대화 상자를 만드는 방법은 무엇입니까?

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

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:gravity="center_vertical" 
android:orientation="vertical" 
android:background="@drawable/dialog" > 

<ImageView 
    android:id="@+id/ivPic" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true"/> 
<ScrollView 
    android:id="@+id/svAlert" 
    android:layout_width="wrap_content" 
    android:layout_below="@+id/ivPic" 
    android:layout_height="200px" 
    > 
    <TextView 
     android:id="@+id/tvMessage" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="text"/> 
</ScrollView> 
<Button 
    android:id="@+id/bOKE" 
    android:gravity="center" 
    android:layout_width="wrap_content" 
    android:layout_below="@+id/svAlert" 
    android:layout_height="wrap_content" 
    android:text="OK"/> 
</RelativeLayout> 

제발 도와 줄 수 있습니까? 당신에 대한 배경을 지정해야

AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.MyDialogTheme)); 
+0

... 어떻게 사용합니까? – ElDuderino

+0

@ user3503360 샘플 용 이미지가 있습니까? – rup35h

답변

0

첫째, 배경 이미지와 사용자 정의 테마를 설정 AlertDialog의 레이아웃. 기본 windowBackground를 사라지게해야합니다. 대화 상자의 android:windowBackground을 투명하게 변경하십시오.

<style name="YourDialogTheme" parent="android:Theme.Dialog"> 
    ... 
    <item name="android:windowBackground">@android:color/transparent</item> 
</style> 
+0

나는 이것을 항상 커스텀 레이아웃을 만들어 내고있다. 나는이 작품을한다면 vl 시도해, u는 mahn입니다. –

+0

사용자 정의 테마가 아니라 사용자 정의 테마를 의미합니다. – penkzhou

+0

이 코드를 어디에 두어야합니까? "my_alert.xml"로 레이아웃 이름을 지정했습니다. 코드에 코드를 삽입해야합니까? – user3503360

0

: 다음

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <style name="MyDialogTheme" parent="android:Theme.Dialog"> 
     <item name="android:windowBackground">@drawable/dialog</item> 
    </style> 
</resources> 

당신의 대화에 테마를 설정합니다 덕분에 전에 ...

관련 문제