2017-01-20 8 views
0

dialogをテーマにしてactivityを作成しました。私はdrawableを丸みのある角でactivity'sの最も外側のPercentRelativeLayoutに貼り付けましたが、角はclippingです。ここではここstyles.xmlダイアログボックスのAndroidスタジオクリッピングコーナー

<style name="myCustomDialog" parent="Theme.AppCompat.Dialog"> 
    <item name="windowActionBar">false</item> 
    <item name="windowNoTitle">true</item> 
</style> 

に私のカスタムdialogであることはここに私のdrawable

<?xml version="1.0" encoding="utf-8"?> 
<shape 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:shape="rectangle"> 

<corners android:radius="5dp" /> 
<stroke 
    android:width="1dip" 
    android:color="#000" /> 
</shape> 

である私の私の

<activity android:name=".activities.NotSavedActivity" 
       android:theme="@style/myCustomDialog"> 
    </activity> 

私は私の活動を開始manifest、コーナーのようにクリッピングされている中activity下の画像に示す

ここ

enter image description hereenter image description here

あなたが見る私のactivity's xml

<?xml version="1.0" encoding="utf-8"?> 
<android.support.percent.PercentRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:padding="15dp" 
android:background="@drawable/not_saved_module"> 

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Du har inte sparat, stäng ändå?" 
    android:id="@+id/notSavedTextView"/> 

<RelativeLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:layout_below="@+id/notSavedTextView"> 
     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/yes" 
      android:text="Ja"/> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/no" 
      android:text="Nej" 
      android:layout_toRightOf="@id/yes" 
      android:layout_toEndOf="@+id/yes"/> 
</RelativeLayout> 

</android.support.percent.PercentRelativeLayout> 

答えて

0

で、あなたの描画可能で任意の背景を設定されていません。実際にあなたのdrawableはコーナーを持つストロークだけです。あなたのドロウアブルにいくつかの塗りつぶしの色( "ソリッド" attr)を設定しようとすると、実際にすべてがきれいです。その背景はTheme.AppCompat.Dialogテーマから来ています。

この

<style name="myCustomDialog" parent="Theme.AppCompat.Dialog"> 
    <item name="windowActionBar">false</item> 
    <item name="windowNoTitle">true</item> 
    <item name="android:background">@android:color/transparent</item> 
</style> 

あるいは

<item name="android:background">@drawable/not_saved_module</item> 

のようなあなたのテーマの何かのSetしかし、第二変形例では、あなたがactivity XMLでそれを設定する必要はありません

関連する問題