Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change soft keys background from black to transparent in android app

I want to change the soft keys(Not sure about name of these buttons all together) background from black to transparent in my app so that users will get a complete visibility of items in listview in my app. I found this feature in Google photos android app. Please that app screenshot here.

https://lh3.googleusercontent.com/_J3bZG-H80ojW-bIz5wPfneLV8s83XViANUZ9Fdh2-qWIsrgX83FbttNb44_cHxj1w=h900-rw

Please some one could help me find a reference document or code to achieve this functionality. Thanks in advance.

like image 465
Anees U Avatar asked Sep 05 '15 09:09

Anees U


People also ask

How do I make a button transparent in XML?

Now it's time to make transparent background of android button. If you want to make 20 % transparent just add 80 at the first of your hex color code like android:background="#80000000" , if you want to make only 80 % transparent button then add 20 at the first of your hex color code like above.


2 Answers

Soft keys all together are called Navigation Bar.

To make it transparent add this line to your activity style (for API 19 and above):

<item name="android:windowTranslucentNavigation">true</item>
like image 90
dzikovskyy Avatar answered Sep 28 '22 12:09

dzikovskyy


This is possible to do for API level 21+ Put this style in your v21/themes.xml and use it as your application theme

<style name="MyApplicationTheme" parent="Theme.AppCompat.NoActionBar">
    <item name="android:navigationBarColor">#4D000000</item>
</style>

Keep in mind that your activity should also be full screen to go below the navigation bar (soft keys)

For an activity that extends AppCompatActivity, you can do it in code by:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
like image 44
Nima K Avatar answered Sep 28 '22 12:09

Nima K