I need to put the top bar outside the " Drawer navigation" .
In my kitkat device , it looks good . but when tested at lollipop that bar appears .
Do not know how to remove it , I tried to change the subject of the activity to " NoActionBar " and similar themas . but it does not work .
Thank you.
I'm doing this design . the kitkat looks good .
lolipop but if you see that bar.
This is my main activity :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.like.mail.network.aupa.maillike.TestActivity">
<include
layout="#layout/top_toolbar" />
<include layout="#layout/content_test" />
</LinearLayout>
This is my content_test:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.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:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include
layout="#layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="left"
android:fitsSystemWindows="true">
<ExpandableListView
android:id="#+id/navigationmenu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#222"
android:groupIndicator="#null"
android:listSelector="#D84B20">
</ExpandableListView>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
This is my manifest:
<activity
android:name=".TestActivity"
android:label="#string/title_activity_test"
android:theme="#style/AppThemeWithoutActionBarTitle">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
This is my style:
<style name="AppThemeWithoutActionBarTitle" parent="AppTheme">
<item name="android:actionBarStyle" tools:targetApi="honeycomb">
#style/ActionBarWithoutTitle
</item>
</style>
<style name="ActionBarWithoutTitle" parent="#style/ActionBar">
<item name="android:displayOptions" tools:targetApi="honeycomb">useLogo</item>
</style>
Try it in manifest
<activity
android:name=".TestActivity"
android:label="#string/title_activity_test"
android:theme="#style/AppThemeWithoutActionBarTitle">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
In res/values-v21/style.xml
<resources>
<style name="AppThemeWithoutActionBarTitle" parent="Base.MyTheme"></style>
<style name="Base.MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowActionBarOverlay">false</item>
<item name="android:windowFullscreen">true</item>
<item name="windowNoTitle">true</item>
</style>
</resources>
Accomplish move the bar with the following code:
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_test);
Also remove the attribute: android: fitsSystemWindows = "true" of all the "layout including" and place it in the main.
Related
I want to change my background color, when my menu item state is "pressed" like this in the image below:
Exmaple
So how to achieve it?
My menu:
<?xml version="1.0" encoding="utf-8"?>
<item android:id="#+id/detail_edit_item"
android:title="#string/edit"
android:icon="#drawable/ic_edit_white"
app:showAsAction="always"/>
<item android:id="#+id/detail_delete_item"
android:title="#string/delete"
android:icon="#drawable/ic_delete_white"
app:showAsAction="always"/>
Here is a workaround which you can use:
For API level 11 or above you can use toolbar widget:
<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"
tools:context="com.test.myapplication.MainActivity">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Titel"
android:layout_alignParentLeft="true" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/background_selector"
android:layout_alignParentRight="true"
/>
</RelativeLayout>
</android.support.v7.widget.Toolbar>
To use this toolbar you have to set NoActionBarTheme for your activity
<activity android:name=".MainActivity"
android:theme="#style/Theme.AppCompat.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I have just used an ImageButton with my custom delete buttons in this example, after that you can write you selector to handle button press as follows:
<?xml version="1.0" encoding="utf-8"?>
<item android:drawable="#drawable/delete" android:state_selected="true"></item>
<item android:drawable="#drawable/delete" android:state_pressed="true"></item>
<item android:drawable="#drawable/delete_not_selected"></item>
You can save this code under drawable folder as background_selector.xml and this should work fine. you can find both images below but delete_not_selected is not visible because it is of white color but you will still be able to download it by clicking on the right side of the delete button.
I originally had an ActionBar atop my Google Map Activity, but I needed to add multiple elements inside it, so it was suggested to me that I use a Toolbar instead.
Well, I've managed to successfully get it setup, but the Toolbar disappears immediately after launching.
I don't understand why this is happening since there are no errors, and I don't know where I would try to add a breakpoint in my code.
Here's the code in my onCreate method of my MapActivity.java:
/*
CODE FOR DISTANCE TEXT AND SHARE BUTTON
*/
if(getSupportActionBar() != null) {
getSupportActionBar().setDisplayShowTitleEnabled(false);
}
Toolbar toolbar = findViewById(R.id.toolbar);
mDrawerLayout = findViewById(R.id.nav_drawer);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
mToggle = new ActionBarDrawerToggle(this,mDrawerLayout,toolbar,R.string.open, R.string.close);
mDrawerLayout.addDrawerListener(mToggle);
mToggle.syncState();
mNavigationView = findViewById(R.id.navigation_view);
if(mNavigationView != null) {
mNavigationView.setNavigationItemSelectedListener(this);
}
Here are the activities in my AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="#drawable/wheres_my_ride_icon"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="***************************" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity
android:name=".MapActivity"
android:screenOrientation="portrait"
android:theme="#style/AppTheme">
</activity>
<activity
android:name=".StartActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".TutorialActivity"
android:label="#string/title_activity_tutorial"
android:theme="#style/AppTheme.NoActionBar">
</activity>
</application>
Here is my styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- Customize theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:textColorSecondary">#android:color/white</item>
</style>
<!-- Action Bar Custom Style -->
<style name="MyActionBar" parent="Theme.AppCompat.Light">
<item name="android:background">#2a363b</item>
<item name="drawerArrowStyle">#style/DrawerHamburgerStyle</item>
<item name="android:textColorSecondary">#android:color/white</item>
</style>
<!-- Action Bar Icon Style -->
<style name="DrawerHamburgerStyle" parent="#style/Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">#android:color/white</item>
</style>
<!-- Custom Alert Dialog Theme -->
<style name="CustomAlertDialog" parent="#android:style/Theme.Dialog">
<item name="android:textColor">#FFFFFF</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
Here is my toolbar.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/minimalist_grey"
android:gravity="center"
app:popupTheme="#style/AppTheme.PopupOverlay">
<TextView
android:id="#+id/toolbarDistanceText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="start|center_vertical"
android:textSize="20sp"
android:text="Distance (Just for testing)" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_share_white"
android:background="#android:color/transparent"
android:layout_gravity="end"
android:layout_marginEnd="20dp"/>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
</LinearLayout>
And here is where I include the toolbar.xml in my activity_map.xml:
<android.support.v4.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"
android:id="#+id/nav_drawer">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- RIGHT HERE IS THE TOOLBAR -->
<include layout="#layout/toolbar"/>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.christopher_sheridan.wheres_my_ride.MapActivity"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp" />
After reading about layouts, I realized I forgot about z-ordering!
I changed my code from this:
<android.support.v4.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"
android:id="#+id/nav_drawer">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- THIS WAS MY OOPSIE -->
<include layout="#layout/toolbar"/>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.christopher_sheridan.wheres_my_ride.MapActivity"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp" />
to this:
<android.support.v4.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"
android:id="#+id/nav_drawer">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.christopher_sheridan.wheres_my_ride.MapActivity"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp" />
<!-- PLACED IT UNDER THE FRAGMENT -->
<include layout="#layout/toolbar"/>
Now the toolbar is there. :-)
ScrollView scrolling stops on toolbar.setVisibility(View.GONE). I have to again scroll to continue scrolling but there's no problem with View.INVISIBLE but Only text of AppBar goes Invisible. I have also tried getSupportActionBar().hide(); but same result Below is my code.
scrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
#Override
public void onScrollChanged() {
int scrollY=scrollView.getScrollY();
if (scrollY>0){
fab.setVisibility(View.INVISIBLE);
if (scrollY>350){
//Here When scrolling reached to 350 scrolling Stops. I have to Scroll Again.
toolbar.setVisibility(View.GONE);
}
Log.d("scrollPosition"," "+scrollY);
}else {
fab.setVisibility(View.VISIBLE);
toolbar.setVisibility(View.VISIBLE);
// I have no problem while scrolling to top.
}
}
});
app_bar_main.xml
<android.support.design.widget.CoordinatorLayout 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="com.queendevelopers.appalamusicplayer.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="#layout/content_main" />
</android.support.design.widget.CoordinatorLayout>
activity_main.xml
<android.support.v4.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:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="#layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="#menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
Styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
Manifest.xml
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I am using Android default templete Android Activity With Navigation Drawer
I am trying to use a transparent toolbar in my app. However, when I set my toolbar as transparent the activity expands to fullscreen height and some content overlaps with my toolbar.
Here is the layout code for the activity:
app_bar_main.xml :
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<include layout="#layout/content_main" />
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#00FFFFFF"/>
</RelativeLayout>
content_main.xml :
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:background="#color/colorPrimary"
tools:context=".MainActivity"
tools:showIn="#layout/app_bar_main">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
</RelativeLayout>
manifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.aaaaa.www.aaaaaaaaa" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
styles.xml :
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
Try adding this to your relative layout xml
android:paddingTop="?android:attr/actionBarSize"
You can try with this:
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#00FFFFFF">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"/>
</android.support.v7.widget.Toolbar>
You are using a RelativeLayout as parent container in app_bar_main.xml where all children will occupy the entire view if set to match parent. You can change it to LinearLayout with vertical mode where Android will arrange the children one by one in vertical direction without overlap.
Try adding this:
<include layout="#layout/content_main" android:layout_below="#+id/toolbar" />
I'm having trouble with applying a custom scheme(style) to certain views. I have defined my own style in res/values/styles.xml
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="myStyle1">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">#color/red</item>
<item name="android:textColorHighlight">#color/blue</item>
<item name="android:textColorHint"> #color/fuchsia</item>
<item name="android:textColorLink">#color/olive</item>
<item name="android:typeface">serif</item>
</style>
<style name="AppTheme" parent="android:Theme.Light" />
</resources>
I have applied this style to the main activity of my simple test application, like this
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main"
android:theme="#style/myStyle1" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
.
.
.
</application>
The layout of the MainActivity contains a couple of buttons, some textViews, some of them have the style attribute spiecified explicitly, others should be inhertiting it from the whole activity.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/layout_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/silver"
android:orientation="vertical" >
<EditText android:id="#+id/edit_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:hint="#string/edit_message" />
<Button android:id="#+id/send_button"
style="#style/myStyle1"
android:text="#string/button_send" />
<Button android:id="#+id/relative_activity"
android:text="#string/rel_activitity_text"
android:onClick="startRelativeActivity"/>
<Button android:id="#+id/button_TTT"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:textColor="#color/red"
android:text="#string/button_TTT" />
<fragment android:name="my.firstapp.Fragment1"
android:background="#color/red"
android:id="#+id/list"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
As far as I can tell, everything in the activity should be stylized according to the style I ahve defined, however, this is what I get
As you can see, only the buttons with the specified style have their text in red, the other two don't. However, even the white buttons get the correct font from the scheme, so at least some of it is being applied. Why not all of it? Any help would be appreciated, I'm thoroughly confused.
If you want a global style for all your buttons you need to do something like this.
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="myStyle1">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">#color/red</item>
<item name="android:textColorHighlight">#color/blue</item>
<item name="android:textColorHint"> #color/fuchsia</item>
<item name="android:textColorLink">#color/olive</item>
<item name="android:typeface">serif</item>
</style>
<style name="AppTheme" parent="android:Theme.Light">
<item name="android:buttonStyle">#style/myStyle1</item>
</style>
</resources>
In your android manifest you should set the theme...
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main"
android:theme="#style/AppTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
.
.
.
</application>
You can do the same thing for checkboxs etc. More information from this link.
http://developer.android.com/reference/android/R.attr.html
Also I tested this on the following layout. All 3 buttons should have red text.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/layout_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffaaaaaa"
android:orientation="vertical" >
<EditText android:id="#+id/edit_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:hint="edit_message" />
<Button android:id="#+id/send_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="button_send" />
<Button android:id="#+id/relative_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="rel_activitity_text"
android:onClick="startRelativeActivity"/>
<Button android:id="#+id/button_TTT"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:textColor="#ffff0000"
android:text="button_TTT" />
<!--<fragment android:name="my.firstapp.Fragment1"
android:background="#00ff0000"
android:id="#+id/list"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />-->
</LinearLayout>