Guest User

Untitled

a guest
May 22nd, 2012
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. Android custom style not showing on a LinearLayout
  2. <style name="Dialog"
  3. parent="@android:style/Theme.Dialog">
  4. <item name="android:windowBackground">@null</item>
  5. <item name="android:windowNoTitle">true</item>
  6. <item name="android:windowIsFloating">true</item>
  7. <item name="android:shadowColor">#FF000000</item>
  8. <item name="android:shadowDx">10</item>
  9. <item name="android:shadowDy">10</item>
  10. <item name="android:shadowRadius">10</item>
  11. </style>
  12.  
  13. <?xml version="1.0" encoding="utf-8"?>
  14. <!-- custom dialog -->
  15. <LinearLayout
  16. xmlns:android="http://schemas.android.com/apk/res/android"
  17. android:id="@+id/layout_root"
  18. android:orientation="vertical"
  19. android:layout_width="wrap_content"
  20. android:layout_height="wrap_content"
  21. android:gravity="center"
  22. android:background="@color/grey"
  23. style="@style/Dialog">
  24. ...
  25.  
  26. public CustomDialog create() {
  27. Typeface tf = Typeface.createFromAsset(context.getAssets(), "fonts/IMPACT.TTF");
  28.  
  29. LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  30. // instantiate the dialog with the custom Theme
  31. final CustomDialog dialog = new CustomDialog(context, R.style.Dialog);
  32.  
  33. View layout = inflater.inflate(R.layout.custom_dialog, null);
  34. dialog.addContentView(layout, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
  35. dialog.setContentView(layout);
  36.  
  37. TextView text = (TextView) layout.findViewById(R.id.text);
  38. text.setTypeface(tf);
  39. text.setText("Add this game to your cal, or share it on Facebook.");
  40.  
  41. return dialog;
  42. }
  43.  
  44. final CustomDialog dialog = new CustomDialog(context, R.style.Dialog);
Advertisement
Add Comment
Please, Sign In to add comment