Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
  2. getSupportActionBar().setCustomView(R.layout.abs_layout);
  3.  
  4. <?xml version="1.0" encoding="utf-8"?>
  5. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  6. android:layout_width="match_parent"
  7. android:layout_height="wrap_content"
  8. android:orientation="vertical" >
  9.  
  10. <TextView
  11. android:layout_width="wrap_content"
  12. android:layout_height="wrap_content"
  13. android:layout_gravity="center"
  14. android:text="my Title"
  15. android:textColor="#ffffff"
  16. android:id="@+id/mytext"
  17. android:textSize="18sp" />
  18.  
  19. </LinearLayout>
  20.  
  21. getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.yourimage)
  22.  
  23. <?xml version="1.0" encoding="utf-8"?>
  24. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  25. android:layout_width="match_parent"
  26. android:layout_height="match_parent"
  27. android:orientation="horizontal"
  28. android:layout_weight="6"
  29. android:background="@android:color/transparent"
  30. >
  31. <RelativeLayout
  32. android:layout_width="0dp"
  33. android:layout_height="match_parent"
  34. android:layout_weight="5"
  35. android:background="@android:color/transparent"
  36. >
  37. <TextView
  38. android:layout_width="match_parent"
  39. android:layout_height="wrap_content"
  40. android:layout_centerInParent="true"
  41. android:id="@+id/action_bar_title"
  42. android:text="@string/app_name"
  43. android:gravity="center_horizontal"
  44. android:textColor="@android:color/white"
  45. android:textAllCaps="false"
  46. android:textStyle="bold"
  47. android:textAppearance="?android:textAppearanceMedium"
  48. />
  49. </RelativeLayout>
  50.  
  51. <RelativeLayout
  52. android:layout_width="0dp"
  53. android:layout_height="match_parent"
  54. android:layout_weight="1"
  55. android:visibility="invisible"
  56. >
  57. <Button
  58. android:layout_width="wrap_content"
  59. android:layout_height="wrap_content"
  60. android:text="sfsdf"
  61. android:layout_centerVertical="true"/>
  62. </RelativeLayout>
  63.  
  64.  
  65. </LinearLayout>
  66.  
  67. getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
  68. getSupportActionBar().setCustomView(R.layout.abs_layout);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement