2017-01-08 12 views
3

アンドロイドのダイアログに影を付け加える方法をお尋ねしたいと思いますか?Androidダイアログの影?

この事を行う方法はありますか?現在、私はダイアログボックスを持っていますが、それは平面であり、影のスタイルではありません。

誰かが私を助けることを願っています。ここで

enter image description here

私activity_dialog.xmlです:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/activity_main" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    tools:context="com.bloxofcode.toggle.MainActivity"> 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:textSize="20sp" 
     android:background="@color/colorHeaderDialog" 
     android:textColor="@android:color/white" 
     android:text="@string/select_gender" 
     android:paddingLeft="5dp" 
     android:paddingTop="15dp" 
     android:paddingBottom="15dp" 
     android:gravity="center_horizontal|left"/> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:padding="5dp"> 
     <EditText 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:textSize="15sp" 
      android:hint="@string/hint_name" 
      android:id="@+id/editText" 
      android:paddingLeft="10dp" /> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal"> 

      <ToggleButton 
       android:text="ToggleButton" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:id="@+id/toggleButtonMale" 
       android:textOn="" 
       android:textOff="" 
       android:focusable="false" 
       android:background="@drawable/check_male" 
       android:layout_weight="1" /> 

      <ToggleButton 
       android:text="ToggleButton" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:id="@+id/toggleButtonFemale" 
       android:textOn="" 
       android:textOff="" 
       android:focusable="false" 
       android:background="@drawable/check_male" 
       android:layout_weight="1" /> 
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      android:paddingTop="5dp"> 
      <Button 
       android:id="@+id/btnCancel" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="Cancel" 
       android:textSize="10dp" 
       android:padding="15dp" 
       android:textColor="@android:color/white" 
       android:layout_weight="1"/> 
      <Button 
       android:id="@+id/btnAccept" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="Accept" 
       android:textSize="10dp" 
       android:padding="15dp" 
       android:background="@color/colorDialogOK" 
       android:textColor="@android:color/white" 
       android:layout_weight="1"/> 
     </LinearLayout> 
    </LinearLayout> 

</LinearLayout> 
+0

いただきました現在のAPIバージョン? – Jayanth

+0

はあなたの応答のための – Jayanth

答えて

0

はこれを試してみてください:

は、新しいテーマに

<style name="dialog_theme"> 
... 
<item name="android:windowBackground">@android:drawable/abc_menu_dropdown_panel_holo_light</item> 
... 
</style> 

を定義し、その後、あなたのダイアログにこのテーマを割り当てる:

Dialog dialog = new Dialog(this, R.style.dialog_theme); 

その描画可能はこの1つしようと動作しなかった場合:

android:background="@android:drawable/dialog_holo_light_frame" 

希望にこの中華鍋を。

+0

こんにちは先生のおかげで私たちにAlertDialogコードを示しているが、どのように私はabc_menu_dropdown_panel_holo_lightしていることができます?それはアンドロイドに組み込まれていますか?または私はそれをPhotoshopのようなイメージエディタで作成する必要がありますか? 2番目のオプションでも、どこに挿入する必要がありますか?あなたの忍耐の先生のための 感謝.. – iamcoder

+0

は、これらのAndroidのデフォルトのドローアブルであり、彼らはあなたがそれらを参照するためにアンドロイドの接頭辞を使用する必要がありますバージョンへのバージョンとは異なる場合があります。これをチェック:http://stackoverflow.com/questions/3201643/how-to-use-default-android-drawables –

0
<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:background="@android:drawable/dialog_holo_light_frame" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context="com.example.bloxofcode.teststyle.MainActivity"> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Hello World!" /> 
</RelativeLayout> 
+0

@NPEこんにちは先生、私はこのようにそれを実装するために、正しいです? – iamcoder

関連する問題