Android Studio Remove ActionBar [closed] - java

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I'm just looking for how I could remove the white bar at the top of the screen :(
EDIT 1
I've been looking for quite a while and hadn't taken the time to do a full question, so here's the code for the two files we're interested in.
I'm using a BottomNavigationBar so I removed the ToolBar because I don't need it. Problem is, it leaves space at the top of the shard set that I can't display anything in.
The style.xml code :
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.LearnCookingV2" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">#color/white</item>
<item name="colorPrimaryVariant">#color/black</item>
<item name="colorOnPrimary">#color/black</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">#color/colorPrimary</item>
<item name="colorSecondaryVariant">#color/colorPrimaryDark</item>
<item name="colorOnSecondary">#color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
And the activity code :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:context=".ui.settings.SettingsFragment">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/rellay1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/grad"
android:paddingBottom="20dp">
<RelativeLayout
android:id="#+id/imgUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:background="#drawable/circle_border">
<ImageView
android:id="#+id/ivProfilePicture"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_margin="15dp"
android:adjustViewBounds="true"
android:background="#drawable/circle"
android:padding="3dp"
android:scaleType="centerInside"
android:src="#drawable/avatar"></ImageView>
</RelativeLayout>
<TextView
android:id="#+id/tvUserPseudo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/imgUser"
android:layout_centerHorizontal="true"
android:layout_marginTop="15sp"
android:text="Pseudo"
android:textColor="#color/white"
android:textSize="32sp" />
</RelativeLayout>
<LinearLayout
android:id="#+id/linlay1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#color/followersBg"
android:gravity="center"
android:paddingTop="5dp"
android:paddingBottom="5dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:id="#+id/tvNbFollowers"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:text="150"
android:textColor="#color/white"
android:textSize="25sp"></TextView>
<TextView
android:id="#+id/tvAbonnes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:text="Abonnés"
android:textColor="#color/white"
android:textSize="25sp"></TextView>
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#color/followingBg"
android:gravity="center"
android:paddingTop="5dp"
android:paddingBottom="5dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:id="#+id/tvNbFollow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:text="350"
android:textColor="#color/white"
android:textSize="25sp"></TextView>
<TextView
android:id="#+id/tvAbonnement"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:text="Abonnements"
android:textColor="#color/white"
android:textSize="25sp"></TextView>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/linlay2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="20dp"
android:layout_marginRight="30dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nom"
android:textColor="#color/headings"
android:textSize="13sp"></TextView>
<TextView
android:id="#+id/tvUserName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:text="Nom"
android:textColor="#000000"
android:textSize="18sp"></TextView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Prénom"
android:textColor="#color/headings"
android:textSize="13sp"></TextView>
<TextView
android:id="#+id/tvUserSurname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:text="Prénom"
android:textColor="#000000"
android:textSize="18sp"></TextView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Email"
android:textColor="#color/headings"
android:textSize="13sp"></TextView>
<TextView
android:id="#+id/tvUserEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:text="Email"
android:textColor="#000000"
android:textSize="18sp"></TextView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mot de passe"
android:textColor="#color/headings"
android:textSize="13sp"></TextView>
<TextView
android:id="#+id/tvUserPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:text="Mot de passe"
android:inputType="textPassword"
android:textColor="#000000"
android:textSize="18sp"></TextView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Age"
android:textColor="#color/headings"
android:textSize="13sp"></TextView>
<TextView
android:id="#+id/tvUserAge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:text="Age"
android:textColor="#000000"
android:textSize="18sp"></TextView>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/linlay3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/linlay2"
android:layout_centerInParent="true"
android:layout_marginLeft="30dp"
android:layout_marginTop="20dp"
android:layout_marginRight="30dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
android:id="#+id/btModify"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/buttonsettings"
android:text="Modifier mon profil" />
<Button
android:id="#+id/btLogout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:background="#drawable/buttonsettings"
android:text="Deconnexion" />
<Button
android:id="#+id/btDelete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_marginBottom="20dp"
android:background="#drawable/buttonsettings"
android:text="Supprimer mon compte" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</ScrollView>
EDIT 2
I deleted the lines that referred to the ToolBar but now the application crashes because of this line in MainActivity :
NavigationUI.setupActionBarWithNavController(this, navController);
All MainActivity :
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
BottomNavigationView navView = findViewById(R.id.nav_view);
AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(R.id.navigation_home, R.id.navigation_category, R.id.navigation_add, R.id.navigation_profile, R.id.navigation_settings).build();
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
NavigationUI.setupActionBarWithNavController(this, navController);
NavigationUI.setupWithNavController(navView, navController);
}
But if I remove that line then everything is fine but the problem persists.

Just go to your styles.xml and change the app theme by replacing whatever actionBar style is provided by NoActionBar.
For example, look at how I have Theme.AppCompat.Light.NoActionBar below.
<!-- Base application theme. -->
<style name="Theme.LearnCookingV2" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">#color/white</item>
<item name="colorPrimaryVariant">#color/black</item>
<item name="colorOnPrimary">#color/black</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">#color/colorPrimary</item>
<item name="colorSecondaryVariant">#color/colorPrimaryDark</item>
<item name="colorOnSecondary">#color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
And remove any line of code in your activity that has something to do with the toolbar. Including the line NavigationUI.setupActionBarWithNavController(this, navController);.
Because it is connecting/setting up the navController with the actionBar which is nothing but the toolbar.

Related

My Navigation Drawer Selected item is not completely covering the whole Menu Area

I am making a navigation drawer using Material Navigation Drawer. I have applied "onNavigationItemSelected" method and the menus are being selected but it only cover the middle area of the menu and leave area at top and bottom. I want the selected menu to cover the whole area, as it should. But i am getting the following result
I have tried to change color of the selected item but no luck thus far.
Here is the code for what I am doing:
XML Layout:
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Ui.Support"
android:fitsSystemWindows="true"
android:id="#+id/consumer_drawer_layout"
tools:openDrawer="start">
<com.google.android.material.navigation.NavigationView
android:background="#color/dark"
app:itemTextColor="#color/white"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/consumer_navbar"
app:menu="#menu/nav_menu_consumer"
android:layout_gravity="start"
app:itemBackground="#drawable/menu_selected"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/light">
<androidx.appcompat.widget.Toolbar
android:id="#+id/support_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/light"
android:minHeight="?attr/actionBarSize"
android:theme="#style/ToolbarTheme"
app:navigationIcon="#drawable/btn_menu_gray"
app:title="SUPPORT"
app:titleTextAppearance="#style/toolbar_title"
app:titleTextColor="#color/dark">
<ImageView
android:id="#+id/support_back_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginEnd="10dp"
android:src="#drawable/btn_back_gray" />
</androidx.appcompat.widget.Toolbar>
<RelativeLayout
android:layout_below="#+id/support_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textview.MaterialTextView
android:id="#+id/contact_us"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:padding="10dp"
android:text="#string/contact_us"
android:textColor="#color/dark"
android:textSize="16sp" />
<com.google.android.material.card.MaterialCardView
android:id="#+id/security_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/contact_us"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
app:cardCornerRadius="8dp"
app:cardElevation="10dp"
app:contentPaddingBottom="21dp"
app:contentPaddingTop="20dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.textview.MaterialTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="14dp"
android:layout_marginBottom="14dp"
android:drawableStart="#drawable/btn_phone"
android:drawablePadding="20dp"
android:text="#string/contact_us_no"
app:fontFamily="#font/avenirltstd_heavy" />
</LinearLayout>
<View
android:id="#+id/view_2"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#android:color/darker_gray" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.textview.MaterialTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="14dp"
android:layout_marginTop="14dp"
android:drawableStart="#drawable/btn_phone"
android:drawablePadding="20dp"
android:text="#string/www_welist_com"
app:fontFamily="#font/avenirltstd_heavy" />
</LinearLayout>
<View
android:id="#+id/view_3"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="14dp"
android:background="#android:color/darker_gray" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.textview.MaterialTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="14dp"
android:layout_marginTop="14dp"
android:drawableStart="#drawable/btn_email"
android:drawablePadding="20dp"
android:text="#string/support_welist_com"
app:fontFamily="#font/avenirltstd_heavy" />
</LinearLayout>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.textview.MaterialTextView
android:id="#+id/social_folllow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/security_card"
android:layout_marginStart="10dp"
android:padding="10dp"
android:text="#string/social_follow"
android:textColor="#color/dark"
android:textSize="16sp" />
<LinearLayout
android:id="#+id/social_links"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/social_folllow"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="5">
<com.google.android.material.card.MaterialCardView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="10dp"
android:layout_weight="1"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
app:cardCornerRadius="8dp"
app:cardElevation="10dp"
app:contentPaddingBottom="15dp"
app:contentPaddingLeft="5dp"
app:contentPaddingRight="5dp"
app:contentPaddingTop="15dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/social_whatsapp" />
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="10dp"
android:layout_weight="1"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
app:cardCornerRadius="8dp"
app:cardElevation="10dp"
app:contentPaddingBottom="15dp"
app:contentPaddingLeft="5dp"
app:contentPaddingRight="5dp"
app:contentPaddingTop="15dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/social_facebook" />
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="10dp"
android:layout_weight="1"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
app:cardCornerRadius="8dp"
app:cardElevation="10dp"
app:contentPaddingBottom="15dp"
app:contentPaddingLeft="5dp"
app:contentPaddingRight="5dp"
app:contentPaddingTop="15dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/social_twitter" />
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="10dp"
android:layout_weight="1"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
app:cardCornerRadius="8dp"
app:cardElevation="10dp"
app:contentPaddingBottom="15dp"
app:contentPaddingLeft="5dp"
app:contentPaddingRight="5dp"
app:contentPaddingTop="15dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/social_linkedin" />
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="10dp"
android:layout_weight="1"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
app:cardCornerRadius="8dp"
app:cardElevation="10dp"
app:contentPaddingBottom="15dp"
app:contentPaddingLeft="5dp"
app:contentPaddingRight="5dp"
app:contentPaddingTop="15dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/social_youtube" />
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
<com.google.android.material.textview.MaterialTextView
android:id="#+id/ask_us"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:padding="10dp"
android:text="#string/ask_us"
android:textColor="#color/dark"
android:textSize="16sp" />
<com.google.android.material.card.MaterialCardView
android:id="#+id/ask_us_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
app:cardCornerRadius="8dp"
app:cardElevation="10dp"
app:contentPaddingBottom="21dp"
app:contentPaddingTop="20dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/subject"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:hint="#string/subject"
android:inputType="text" />
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/support_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:hint="#string/message"
android:inputType="text" />
<com.google.android.material.button.MaterialButton
android:id="#+id/ask_us_btn"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginStart="15dp"
android:layout_marginTop="15dp"
android:layout_marginEnd="15dp"
android:text="#string/submit"
app:backgroundTint="#color/main"
app:cornerRadius="8dp" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
</ScrollView>
</androidx.drawerlayout.widget.DrawerLayout>
I am following an online tutorial but their result is different from mine.
I am also using menu items in groups because of achieving dividers in between the Items.
Here is the Menu layout:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group
android:id="#+id/group_item_1"
android:checkableBehavior="single">
<item
android:id="#+id/nav_home"
android:icon="#drawable/menu_home"
android:title="#string/home" />
</group>
<group
android:id="#+id/group_item_2"
android:checkableBehavior="single">
<item
android:id="#+id/nav_profile"
android:icon="#drawable/menu_profile"
android:title="#string/profile" />
</group>
<group
android:id="#+id/group_item_3"
android:checkableBehavior="single">
<item
android:id="#+id/nav_categories"
android:icon="#drawable/menu_categories"
android:title="#string/all_categories" />
</group>
<group
android:id="#+id/group_item_4"
android:checkableBehavior="single">
<item
android:id="#+id/nav_nearby_brands"
android:icon="#drawable/menu_nearby"
android:title="#string/brand_nearby" />
</group>
<group
android:id="#+id/group_item_5"
android:checkableBehavior="single">
<item
android:id="#+id/nav_professionals"
android:icon="#drawable/menu_professional"
android:title="#string/professionals" />
</group>
<group
android:id="#+id/group_item_6"
android:checkableBehavior="single">
<item
android:id="#+id/nav_vendors"
android:icon="#drawable/menu_vendor"
android:title="#string/vendors" />
</group>
</menu>
Here is my Java Class:
public class Support extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
DrawerLayout drawerLayout;
NavigationView navigationView;
Toolbar support_toolbar;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_support);
drawerLayout = findViewById(R.id.consumer_drawer_layout);
navigationView = findViewById(R.id.consumer_navbar);
support_toolbar = findViewById(R.id.support_toolbar);
setSupportActionBar(support_toolbar);
navigationView.setItemIconTintList(null);
navigationView.bringToFront();
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawerLayout, support_toolbar, R.string.nav_open, R.string.nav_close);
drawerLayout.addDrawerListener(toggle);
toggle.syncState();
navigationView.setNavigationItemSelectedListener(this);
}
#Override
public void onBackPressed() {
if (drawerLayout.isDrawerOpen(GravityCompat.START)) {
drawerLayout.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}
#Override
public boolean onNavigationItemSelected(#NonNull MenuItem item) {
return true;
}
}
Instead of creating group for each item, merge all your items in a single group like below:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:showIn="navigation_view">
<group
android:id="#+id/group_item_1"
android:checkableBehavior="single">
<item
android:id="#+id/nav_home"
android:icon="#drawable/menu_home"
android:title="#string/home" />
<item
android:id="#+id/nav_profile"
android:icon="#drawable/menu_profile"
android:title="#string/profile" />
<item
android:id="#+id/nav_categories"
android:icon="#drawable/menu_categories"
android:title="#string/all_categories" />
<item
android:id="#+id/nav_nearby_brands"
android:icon="#drawable/menu_nearby"
android:title="#string/brand_nearby" />
<item
android:id="#+id/nav_professionals"
android:icon="#drawable/menu_professional"
android:title="#string/professionals" />
<item
android:id="#+id/nav_vendors"
android:icon="#drawable/menu_vendor"
android:title="#string/vendors" />
</group>
</menu>
And then add divider like below:
navigationView = findViewById(R.id.consumer_navbar);
NavigationMenuView navMenuView = (NavigationMenuView) navigationView.getChildAt(0);
navMenuView.addItemDecoration(new DividerItemDecoration(Support.this,DividerItemDecoration.VERTICAL));

No Ripple Effect in RecyclerView

I am using RecyclerView to display quote list Fragment. I am trying to use Ripple effect in list item but its not working. My RecyclerView is like below
<android.support.v7.widget.RecyclerView
android:id="#+id/listQuoteView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/BackColor"
android:layout_above="#+id/startAppBanner"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
And List Item XML is like below
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="4dp"
app:cardCornerRadius="6dp"
app:cardElevation="4dp">
<LinearLayout
android:id="#+id/quoteActionView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/TextColor"
android:clickable="true"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageAuthorView"
android:layout_width="#dimen/imageAuthorView"
android:layout_height="#dimen/imageAuthorView"
android:visibility="visible" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/textQuote"
android:ellipsize="end"
android:layout_width="match_parent"
android:layout_height="0dp"
android:paddingRight="#dimen/list_text_margin"
android:paddingLeft="#dimen/list_text_margin"
android:gravity="center_vertical"
android:layout_weight="2"
android:maxLines="2"
android:layout_margin="2dp"
android:lineSpacingExtra="#dimen/linespace"
android:textColor="?attr/MainTextColor"
android:text="Hello there two line text for show here which I am typing for a test"
android:scrollHorizontally="true"
android:textSize="#dimen/textDetailQuote"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:background="?attr/dark_color"
android:orientation="horizontal">
<ImageView
android:layout_width="#dimen/likeIcon"
android:layout_height="#dimen/likeIcon"
android:layout_weight="1"
android:tint="?attr/List_Text"
android:src="#drawable/time_new_ic" />
<TextView
android:id="#+id/lblTimeCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="00:00"
android:textStyle="bold"
android:textColor="?attr/List_Text"
android:textSize="#dimen/lblTime" />
<ImageView
android:layout_width="#dimen/likeIcon"
android:layout_height="#dimen/likeIcon"
android:layout_weight="1"
android:tint="?attr/List_Text"
android:src="#drawable/fav_new_ic" />
<TextView
android:id="#+id/lblLikeCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="200"
android:textStyle="bold"
android:textColor="?attr/List_Text"
android:textSize="#dimen/lblTime" />
<ImageView
android:layout_width="#dimen/likeIcon"
android:layout_height="#dimen/likeIcon"
android:layout_weight="1"
android:tint="?attr/List_Text"
android:src="#drawable/share_new_ic" />
<TextView
android:id="#+id/lblShareCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textStyle="bold"
android:text="100"
android:textColor="?attr/List_Text"
android:textSize="#dimen/lblTime" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
I have tried many solutions listed in stackoverflow but not worked any. If I remove CardView from List Item.... Ripple Effect shows itself behind LinearLayout but I want to use CardView also. Let me know if someone can help me to solve this issue. Thanks.
Note : I have solved it using this solution. Thanks
Set the ripple as a foreground drawable on the CardView:
android:foreground="?attr/selectableItemBackground"
This will allow the ripple to show up above the content inside the CardView, which is usually what you want for a CardView
Create ripple drawable and set it as foreground of your layout
ripple.xml
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:color="#color/your_color"
tools:targetApi="lollipop">
<item android:id="#android:id/mask">
<shape android:shape="rectangle">
<solid android:color="#color/your_color" />
</shape>
</item>
</ripple>
Change your code like this:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:clickable="true"
android:foreground="#drawable/ripple"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="4dp"
app:cardCornerRadius="6dp"
app:cardElevation="4dp">
Use android:background="?android:attr/selectableItemBackground"

Not getting style on text view

I have tried adding style to my text. I am getting the style executed on some edit text and not getting executed on some other edit text. Unable to understand what's going wrong. Here is my output
I can view style on edit text view of Location details from and not on edit text view of Location details to.
please help..
Style XML
<style name="AudioFileInfoOverlayText">
<item name="android:paddingLeft">4px</item>
<item name="android:paddingBottom">4px</item>
<item name="android:textColor">#ffffffff</item>
<item name="android:textSize">12sp</item>
<item name="android:shadowColor">#000000</item>
<item name="android:shadowDx">1</item>
<item name="android:shadowDy">1</item>
<item name="android:shadowRadius">1</item>
</style>
Activity Layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#android:color/white"
android:layout_marginLeft="15dp"
android:layout_marginTop="10dp"
android:layout_marginRight="15dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/DriversNear"
android:id="#+id/textView10"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp" />
<fragment android:layout_width="match_parent"
android:layout_height="200dp"
android:id="#+id/map"
tools:context=".GoRideActivity"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_marginTop="10dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#android:color/white"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_weight="0.3"
android:layout_marginTop="05dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/From"
android:id="#+id/textView11"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="08dp"
android:id="#+id/imageView11"
android:background="#drawable/line2"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:id="#+id/imageView10"
android:layout_marginStart="20dp"
android:background="#drawable/ic_place_black_48dp"
android:layout_marginTop="05dp"
android:layout_gravity="center" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/Text_from"
android:text="#string/Loc"
android:visibility="visible"
android:drawableEnd="#drawable/ic_chevron_right_black_24dp"
android:layout_marginEnd="10dp"
android:layout_gravity="center"
android:textAppearance="#android:style/TextAppearance.Medium"
android:layout_marginTop="05dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:focusable="true"
android:focusableInTouchMode="true">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:id="#+id/imageView12"
android:layout_marginStart="20dp"
android:background="#drawable/ic_description_black_48dp"
android:layout_marginTop="15dp" />
<EditText
android:layout_width="match_parent"
android:layout_height="45dp"
android:id="#+id/editText_from_details"
android:layout_marginEnd="10dp"
android:hint="#string/LocationDetails"
android:cursorVisible="true"
style="#style/AudioFileInfoOverlayText"
android:textColor="#android:color/transparent"
android:layout_gravity="center" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="#+id/textViewHouseDetailsFrom"
android:layout_marginStart="48dp"
style="#style/AudioFileInfoOverlayText"
android:text="#string/HouseDetails" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#android:color/white"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_weight="0.3">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/To"
android:id="#+id/textView14"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp" />
<ImageView
android:layout_width="match_parent"
android:layout_height="08dp"
android:id="#+id/imageView14"
android:background="#drawable/line2"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:id="#+id/imageView15"
android:layout_marginStart="20dp"
android:background="#drawable/ic_place_black_48dp"
android:layout_marginTop="05dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/Text_to"
android:drawableEnd="#drawable/ic_chevron_right_black_24dp"
android:layout_marginEnd="10dp"
android:text="#string/Loc"
android:layout_gravity="center"
android:layout_marginTop="05dp"
android:textAppearance="#android:style/TextAppearance.Medium" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:id="#+id/imageView17"
android:layout_marginStart="20dp"
android:background="#drawable/ic_description_black_48dp"
android:layout_marginTop="15dp" />
<EditText
android:layout_width="match_parent"
android:layout_height="45dp"
android:id="#+id/editText_to_details"
android:layout_marginEnd="10dp"
android:hint="#string/LocationDetails"
style="#style/AudioFileInfoOverlayText" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="#+id/textViewHouseDetailsTo"
android:layout_marginStart="48dp"
android:text="#string/HouseDetails"
style="#style/AudioFileInfoOverlayText" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/circle"
android:layout_gravity="center"
android:layout_marginTop="30dp">
<ImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:id="#+id/imageView_next"
android:layout_gravity="center_horizontal"
android:layout_weight="0.42"
android:background="#drawable/ic_chevron_right_black_48dp"
/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/next"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:textAppearance="#android:style/TextAppearance.Holo.Large" />
</LinearLayout></ScrollView>
</LinearLayout>
Add a resource reference in style.xml. Following is an example. hope this will help.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style
name="style_name"
parent="#[package:]style/style_to_inherit">
<item
name="[package:]style_property_name"
>style_value</item>
</style>
</resources>

How to change change text and arrow color on Toolbar?

I am currently building an app using the new material design guidelines.
I am using a Toolbar rather than an action bar.
I want the text, overflow icon, and the arrow/hamburger icon (thing that flips over when you pull out the navigation draw) to be white rather than black, but the rest of my theme needs to be the AppCompat.light theme.
If someone could please explain how i would go about changing these things, i would be very greatful.
I also need to change the colors both in xml and via java code.
And on a sub note, does anyone know how i set a sub-text in the toolbar? I read it is possible, but i cant find any resources on how it is done.
<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimaryDark"
xmlns:android="http://schemas.android.com/apk/res/android"
/>
<com.bacon.corey.audiotimeshift.SlidingUpPanelLayout xmlns:sothree="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:panelHeight="0dp"
sothree:shadowHeight="10dp"
sothree:paralaxOffset="100dp"
sothree:fadeColor="#android:color/transparent"
>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<!-- The main content view -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:padding="0dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:padding="0dip"
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:id="#+id/recordingListMainLayout"
android:foreground="#drawable/dim_shadow_shape_dark"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:padding="0dp"
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/mainLayoutContainer"/>
<!--
<android.support.v4.view.ViewPager
android:id="#+id/viewPager"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"
android:padding="0dp"
android:layout_margin="0dp"
/>
-->
</LinearLayout>
</FrameLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/textview_rounded_corner_background_fam"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="33dp"
android:layout_marginRight="90dp"
android:id="#+id/fabMainText"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Main Option - Quick Record"
android:textAlignment="center"
android:padding="6dp"
android:fontFamily="sans-serif-medium"
/>
</FrameLayout>
<com.bacon.corey.audiotimeshift.FloatingActionsMenu
android:id="#+id/fabMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:gravity="right"
app:fab_addButtonColorNormal="#color/holo_red_light"
app:fab_addButtonColorPressed="#color/c16"
app:fab_addButtonPlusIconColor="#color/white"
app:fab_expandDirection="up"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:layout_marginEnd="10dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/textview_rounded_corner_background_fam"
android:layout_marginRight="14dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Option Four"
android:textAlignment="center"
android:padding="6dp"
android:fontFamily="sans-serif-medium"
/>
</FrameLayout>
<com.bacon.corey.audiotimeshift.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fab_colorNormal="#color/c15"
app:fab_colorPressed="#color/c15"
app:fab_size="mini"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/textview_rounded_corner_background_fam"
android:layout_marginRight="14dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Option Three"
android:textAlignment="center"
android:padding="6dp"
android:fontFamily="sans-serif-medium"
/>
</FrameLayout>
<com.bacon.corey.audiotimeshift.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fab_colorNormal="#color/c8"
app:fab_colorPressed="#color/c8"
app:fab_size="mini"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/textview_rounded_corner_background_fam"
android:layout_marginRight="14dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Option Two"
android:textAlignment="center"
android:padding="6dp"
android:fontFamily="sans-serif-medium"
/>
</FrameLayout>
<com.bacon.corey.audiotimeshift.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fab_colorNormal="#color/a1"
app:fab_colorPressed="#color/a1"
app:fab_size="mini"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/textview_rounded_corner_background_fam"
android:layout_marginRight="14dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Option One"
android:textAlignment="center"
android:padding="6dp"
android:fontFamily="sans-serif-medium"
/>
</FrameLayout>
<com.bacon.corey.audiotimeshift.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fab_colorNormal="#color/a2"
app:fab_colorPressed="#color/a2"
app:fab_size="mini"
/>
</LinearLayout>
</com.bacon.corey.audiotimeshift.FloatingActionsMenu>
</RelativeLayout>
</RelativeLayout>
<!-- The navigation drawer -->
<ListView android:id="#+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="#android:color/transparent"
android:dividerHeight="0dp"
android:background="#FFFFFF"/>
</android.support.v4.widget.DrawerLayout>
<!-- Sliding Panel Layout -->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center|top"
android:textSize="16sp"
android:id="#+id/slideUpPanel"
>
</FrameLayout>
</com.bacon.corey.audiotimeshift.SlidingUpPanelLayout>
</LinearLayout>
Thanks in advance for any help.
Corey B :)
Here is complete style for your toolbar. Explanation is given inline.
<style name="MyToolbar" parent="#style/ThemeOverlay.AppCompat">
<!-- Title text -->
<item name="android:textColorPrimary">#android:color/white</item>
<!-- Title color in AppCompat.Light -->
<item name="android:textColorPrimaryInverse">#android:color/white</item>
<!-- Menu text-->
<item name="actionMenuTextColor">#android:color/white</item>
<!-- Overflow -->
<item name="android:textColorSecondary">#android:color/white</item>
<!-- This will change drawer icon -->
<item name="drawerArrowStyle">#style/WhiteDrawerIconStyle</item>
<!-- background of the -->
<!-- <item name="android:background">#color/color_primary</item> -->
</style>
<style name="WhiteDrawerIconStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">#android:color/white</item>
</style>
On subtitle note: You can use mToolbar.setSubtitle(sutitle);
Put app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
to your Toolbar xml. And arrow turns white.
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="#dimen/toolbar_height"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
In your app bar, add this property.
app:theme = "#style/Base.V7.Theme.AppCompat"
That should take care of all the whiting. The referenced theme consists of a toolbar with white items, so the toolbar takes the part of the theme that is relevant to it.
Call mToolbar.setSubtitle as discussed above.

how to set height & width of android rating bar?

i want to set height of rating bar to 23 dp & width to 110 dp .
here is image(url) of layout i require :
here is my xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="70dp"
android:background="#color/white"
android:padding="2dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView1"
android:layout_width="55dp"
android:layout_height="55dp"
android:layout_margin="5dp" />
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="vertical"
android:layout_weight="1"
android:paddingTop="5dp">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="waiter_one"
android:textColor="#color/black"
/>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="dfddd"
android:layout_marginTop="3dp" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ssss" />
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1710 votes"
android:layout_gravity="bottom" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/rateing_bg" />
</LinearLayout>
//Commented code of rating bar
comment(start)
<RatingBar
android:id="#+id/ratingBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="5"
android:maxWidth="110dp"
android:maxHeight="23dp" /> comment(end)
</LinearLayout>
</LinearLayout>
code of rating bar is commented .If i remove comment then causing lot of problem.
You have to use a style for your rating bar,for example:
<style name="foodRatingBarSmall" parent="#android:style/Widget.RatingBar.Small">
<item name="android:progressDrawable">#drawable/food_ratingbar_small</item>
<item name="android:minHeight">16dip</item>
<item name="android:maxHeight">16dip</item>
</style>
For more details Check This.

Categories