2017-07-23 35 views
0

Custom Background自定義形狀對話框

我想在這個shape..i一個活動應用對話主題日這個清單中,但如何讓這個形象,我的對話框形狀

我的活動是

@Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     requestWindowFeature(Window.FEATURE_NO_TITLE); 
     setContentView(R.layout.success); 

    } 

我的XML是

<?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="match_parent" 
    android:background="@android:color/transparent"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_margin="8dp" 
     android:background="@drawable/custom_dialog"> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_margin="16dp" 
      android:layout_centerInParent="true"> 

      <TextView 
       android:id="@+id/success" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:padding="16dp" 
       android:text="You have successfully signed in with LinkedIn" 
       android:textAlignment="center" 
       android:textColor="@color/dia_text" 
       android:textSize="24sp" /> 

      <TextView 
       android:id="@+id/personalise" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/success" 
       android:layout_centerInParent="true" 
       android:layout_marginTop="16dp" 
       android:padding="8dp" 
       android:text="Lets, personalise Conext!" 
       android:textAlignment="center" 
       android:textColor="@color/dia_text_con" 
       android:textSize="22sp" /> 

      <ImageView 
       android:id="@+id/nextBtn" 
       android:layout_width="80dp" 
       android:layout_height="80dp" 
       android:layout_below="@+id/personalise" 
       android:layout_centerInParent="true" 
       android:layout_marginTop="8dp" 
       android:src="@drawable/next_icon" /> 

     </RelativeLayout> 

    </RelativeLayout> 

</RelativeLayout> 

進出口新到Android,很抱歉,如果我的問題是太silly.Canÿ OU請幫我

我Mamifest

<activity 
     android:name=".ui.SuccessPopUp" 
     android:screenOrientation="portrait" 
     android:theme="@android:style/Theme.DeviceDefault.Light.Dialog" /> 

回答

1

因爲你的活動是你的對話框,你必須創建一個自定義對話框主題。在styles.xml中添加以下行。

<resources> 
<style name="MyDialogTheme" parent="android:Theme.Dialog"> 
     <item name="android:background">#00000000</item> 
</style> 
</resources> 

也更改清單文件中的主題。

<activity 
    android:name=".ui.SuccessPopUp" 
    android:screenOrientation="portrait" 
    android:theme="@android:@style/MyDialogTheme" /> 

最後,將佈局的背景更改爲您的圖像並刪除第二個RelativeLayout。

+0

能否請您詳細說明 –

+0

查看編輯後的答案。希望現在清楚。 – Abhi

+0

爲什麼和我應該在哪裏使用 - >最終的對話框d =新的對話框(this,android.R.style.Theme_Translucent_NoTitleBar_Fullscreen); d.setContentView(R.layout.custom); return d; –