amjadArabia

Toolbar

Mar 13th, 2018
513
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.83 KB | None | 0 0
  1. Adding Toolbar
  2.  
  3. values --> colors
  4. --------------------
  5. <color name="toolbar_color">#64c5cae9</color>
  6.  
  7. =============================================================================================================
  8.  
  9. activity.xml
  10. --------------------
  11.     <android.support.v7.widget.Toolbar
  12.         android:id="@+id/toolbar_top"
  13.         android:layout_height="wrap_content"
  14.         android:layout_width="match_parent"
  15.         android:minHeight="?attr/actionBarSize"
  16.         android:background="@color/toolbar_color" >
  17.     </android.support.v7.widget.Toolbar>
  18.  
  19.     <ImageView
  20.         android:layout_width="65dp"
  21.         android:layout_height="50dp"
  22.         android:layout_alignBottom="@+id/toolbar_top"
  23.         android:layout_centerHorizontal="true"
  24.         android:background="@drawable/a1" />
  25.  
  26.     <ImageView
  27.         android:id="@+id/toolbar_img"
  28.         android:layout_width="wrap_content"
  29.         android:layout_height="wrap_content"
  30.         android:layout_alignParentStart="true"
  31.         android:layout_alignParentTop="true"
  32.         android:background="@drawable/back_arrow"
  33.         android:visibility="invisible" />
  34.  
  35.     <ImageView
  36.         android:id="@+id/toolbar_img1"
  37.         android:layout_width="wrap_content"
  38.         android:layout_height="wrap_content"
  39.         android:layout_alignParentEnd="true"
  40.         android:layout_alignParentTop="true"
  41.         android:background="@drawable/back_arrow"
  42.         android:visibility="invisible" />
  43.  
  44. ===============================================================================================================
  45.  
  46. Create 1 drawable file "back_arrow.xml"
  47. -------------------------
  48. <vector xmlns:android="http://schemas.android.com/apk/res/android"
  49.     android:width="55dp"
  50.     android:height="55dp"
  51.     android:viewportWidth="24.0"
  52.     android:viewportHeight="24.0">
  53.     <path
  54.         android:fillColor="#88000000"
  55.         android:pathData="M15.41,16.09l-4.58,-4.59 4.58,-4.59L14,5.5l-6,6 6,6z"/>
  56. </vector>
  57. ==============================================================================================================
  58.  
  59. MainActivity.java
  60. ----------------------
  61. ImageView toolbar_img,toolbar_img1;
  62.  
  63. setPointer {
  64.  
  65.     Toolbar toolbarTop = (Toolbar) findViewById(R.id.toolbar_top);
  66.     toolbar_img = findViewById(R.id.toolbar_img);
  67.         toolbar_img1 = findViewById(R.id.toolbar_img1);
  68.  
  69.  
  70.         if (Locale.getDefault().getLanguage().equals("en")) {      // check if user have english langue in device
  71.  
  72.             toolbar_img.setVisibility(View.VISIBLE);       // visible the correct photo
  73.         }
  74.         else {
  75.             toolbar_img1.setVisibility(View.VISIBLE);
  76.             toolbar_img.setVisibility(View.INVISIBLE);    // invislbe the invalid photo
  77.         }
  78.            
  79.  
  80. }
  81.  
  82. =========================================================================================================
Advertisement
Add Comment
Please, Sign In to add comment