2017-07-23 32 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; –