Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android upper Copy/Paste toolbar

I need your assistance with the following issue in android dev. For some reason when I extend ActioBarActivity the cut/copy/paste buttons are displayed correctly when I press the EditText component (see image 1).

enter image description here

Unfortunately, if I extend Activity, the toolbar is not displayed correctly. You can see on image 2, that the buttons are present but they are white and the user cannot see them. I have investigated but I'm not sure how to fix this.

enter image description here

If you need I can share the code but I think this can be easily reproduced.

Thanks in advance.

Paul

like image 264
TerminatorX Avatar asked Dec 20 '22 09:12

TerminatorX


2 Answers

Try using this in the definition of your app theme:

<item name="actionModeBackground">@color/actionBarBgColor</item>
like image 116
zajac.m2 Avatar answered Jan 09 '23 04:01

zajac.m2


Create a custom style and specify the background to the color you want, and in your theme xml resource file, between the "style" element, set the "android:actionBarStyle" to the custom style you just created, it'll change the action bar color for you.

Updated: I just used the default folder for my theme resource (Note: the file name is arbitrary), if you want to create a theme resource for v-11 (API level 11) and up, create a new theme resource file (again, file name is arbitrary) with a "-v11" suffixed to the name of the file.

Folder structure

This is the default theme resource file since it inherits properties and attributes from the Theme.AppCompat.Light.DarkActionBar, as you can notice, in this file, you MUST not use the "android" namespace. If you have another theme resource file, like in the picture above, Android Studio automatically created the stylex.xml(v21) which is for Android version 21 and up devices. You MUST add the "android" namespace to each and every attribute such as the actionBarStyle would become android:actionBarStyle, but you should now that, the ActionBar has been deprecated since version 21, API level 5.

Also, the displayOptions attribute tells Android about how the title area is shown. These are availabe values:

  1. none
  2. useLogo
  3. showHome
  4. homeAsUp
  5. showTitle
  6. showCustom
  7. disableHome

Note: the background attribute ONLY accepts reference value, not hard-coded value.

The default theme resource file

Here is the result

Final result

like image 23
Biu Avatar answered Jan 09 '23 02:01

Biu