I have been using a few images for buttons (the XML below) - but a part of my project I have needed to create a button programmatically, which is not formatted like this others (which I would like it to be).
Buttonshape.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_focused="true"
android:state_pressed="true"
android:drawable="#drawable/button" />
<item
android:state_focused="false"
android:state_pressed="true"
android:drawable="#drawable/button" />
<item android:drawable="#drawable/buttonpressed" />
</selector>
My code that creates a button
Button newBut;
newBut = new Button(this);
newBut.setText("SOME TEXT");
newBut.setTextColor(Color.parseColor("#404040"));
newBut.setEllipsize(TruncateAt.MARQUEE);
newBut.setSingleLine();
newBut.setMarqueeRepeatLimit(50);
newBut.setSelected(true);
This is the code from a Activity with the formatted buttons
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.tabdemo.Tab1Activity"
android:background="#00547d"
>
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:orientation="vertical"
android:weightSum="1">
<Button
android:id="#+id/button1"
android:layout_width="match_parent"
android:layout_height="60dp"
android:text="Login"
android:textColor="#FFFFFF"
android:textSize="20dp"
android:background="#drawable/buttonshape"
android:shadowColor="#A8A8A8"
android:shadowDx="0"
android:shadowDy="0"
android:shadowRadius="5"
/>
<Button
android:id="#+id/button2"
android:enabled="false"
android:text="Logout"
android:textColor="#FFFFFF"
android:textSize="20dp"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#drawable/buttonshape"
android:shadowColor="#A8A8A8"
android:shadowDx="0"
android:shadowDy="0"
android:shadowRadius="5"
/>
</LinearLayout>
</RelativeLayout>
Is there any way of using android:background="#drawable/buttonshape" programatically
try this:
button.setBackgroundDrawable(ContextCompat.getDrawable(this, R.drawable.buttonshape));
Related
I wanna make my text view is like this
i wanna take just background (rounded on edge only)
Try this
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_delete" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/button_background"
android:orientation="horizontal"
android:padding="5dp">
<EditText
android:id="#+id/myEDT"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_margin="2dp"
android:background="#null"
android:hint="Enter Text" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_delete" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_delete" />
</LinearLayout>
</LinearLayout>
button_background
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="50dp" />
<stroke android:width="2dp" android:color="#color/colorPrimary" />
<solid android:color="#ffffff" />
</shape>
OUTPUT
It's working good and everything else is good but the size of Facebook button is not good.
I tried to edit it from xml in several ways but button size remains the same
Can anyone please Help?
<EditText
android:id="#+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/prompt_password"
android:imeActionId="#+id/login"
android:imeActionLabel="#string/action_sign_in_short"
android:imeOptions="actionUnspecified"
android:inputType="textPassword"
android:maxLines="1" />
<Button
android:id="#+id/forgot_password"
android:layout_marginTop="8dp"
android:text="#string/forgot_password"
android:layout_gravity="end"
android:typeface="normal"
android:textSize="14sp"
style="#style/Widget.AppCompat.Button.Borderless"
android:background="#drawable/tw__transparent"
android:layout_height="38dp"
android:layout_width="130dp" />
<Button
android:id="#+id/email_sign_in_button"
style="?android:textAppearanceSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="#string/action_sign_in"
android:background="#drawable/rounded_corners"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/facebook_login"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
android:orientation="horizontal">
<com.facebook.login.widget.LoginButton
android:id="#+id/facebook_login_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
<ProgressBar
android:id="#+id/login_progress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone" />
if You can Use Padding Like this so increase size but this in use worst case
<com.facebook.login.widget.LoginButton
android:id="#+id/facebook_login_button"
android:layout_width="match_parent"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:layout_height="wrap_content"/>
<!-- in reguler case customise button with xml
in Drawable ic_facebook_button-->
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="32dp" />
<solid android:color="#5476b8" />
<padding
android:bottom="5dp"
android:left="5dp"
android:right="5dp"
android:top="5dp" />
</shape>
//Use in Layout xml
<Button
android:id="#+id/buttonFacebook"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_alignParentBottom="true"
android:layout_marginTop="9dp"
android:background="#drawable/facebookbutton"
android:text="#string/facebook_connect"
android:textAllCaps="true"
android:drawableLeft="#drawable/ic_facebook"
android:textColor="#color/colorWhite"
android:textSize="18sp" />
you can specify height
<com.facebook.login.widget.LoginButton
android:id="#+id/facebook_login_button"
android:layout_width="match_parent"
android:layout_height="50dp"/>
increase height as per requirement
I have RelativeLayout below android.support.v7.widget.Toolbar. They both have the same color. How can I get rid of devider between them?
Here is xml code:
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="#color/HomeColorPrimary"
android:minHeight="?attr/actionBarSize"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light">
</android.support.v7.widget.Toolbar>
<RelativeLayout
android:layout_below="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="120dp"
android:id="#+id/spaceBelowToolbar"
android:background="#color/HomeColorPrimary"
android:orientation="vertical"
android:elevation="4dp">
</RelativeLayout>
Here is the full xml file :
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/mainBody"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/MainBG">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="#color/HomeColorPrimary"
android:minHeight="?attr/actionBarSize"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light">
</android.support.v7.widget.Toolbar>
<RelativeLayout
android:layout_below="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="120dp"
android:id="#+id/spaceBelowToolbar"
android:background="#color/HomeColorPrimary"
android:orientation="vertical"
android:elevation="4dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="42dp"
android:layout_alignParentLeft="true"
android:id="#+id/MoneyValue"
android:textColor="#color/md_white_1000"
android:textSize="45sp"
android:text="$850"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/MoneyValue"
android:id="#+id/Balance"
android:layout_marginLeft="42dp"
android:textSize="25sp"
android:textColor="#color/md_grey_300"
android:text="BALANCE"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="180dp"
android:id="#+id/PercentageValue"
android:textColor="#color/md_white_1000"
android:textSize="45sp"
android:text="93%"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/PercentageValue"
android:textColor="#color/md_grey_300"
android:id="#+id/Budget"
android:layout_marginLeft="180dp"
android:textSize="25sp"
android:text="BUDGET"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/listViewLayout"
android:layout_below="#+id/spaceBelowToolbar"
>
<ExpandableListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp">
<com.github.clans.fab.FloatingActionMenu
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginRight="15dp"
android:layout_marginBottom="30dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
fab:menu_labels_style="#style/MenuLabelsStyle"
fab:menu_labels_showAnimation="#anim/jump_from_down"
fab:menu_labels_hideAnimation="#anim/jump_to_down"
fab:menu_animationDelayPerItem="0"
fab:menu_shadowColor="#444"
fab:menu_colorNormal="#FFB805"
fab:menu_colorPressed="#F2AB00"
fab:menu_colorRipple="#D99200">
</com.github.clans.fab.FloatingActionMenu>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
The most concise answer and easiest for me was applying it like so based on the comment. However, Since I have my toolbar wrapped by an app overlay I had to apply it to the AppBarLayout widget for it to work.
<!--takes away line with app elevation set to 0 -->
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay"
app:elevation="0dp">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#drawable/email_bg"
app:popupTheme="#style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
you may have to set a custom background and custom style for the ActionBar. Try using the this actionbar theme, it should set a completely solid background (no divider line):
<!-- Base application theme. -->
<style name="AppTheme"
parent="#android:style/Theme.Holo.Light">
<!--this removes the shadow under the action bar-->
<item name="android:windowContentOverlay">#null</item>
<item name="android:actionBarStyle">#style/MyActionBarStyle</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBarStyle"
parent="#android:style/Widget.Holo.Light.ActionBar.Solid">
<item name="android:background">#color/HomeColorPrimary</item>
</style>
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.
Below is a screen shot of a custom edit text field i have in my android app. While you are type a given word, the text for the word you are currently typing highlights in grey and shows the text as black, until you hit the space bar at which time the text turns white as expected. Is there a way to change the color of the highlight and the text that is highlighted?
my edit text xml looks like this
<EditText
android:id="#+id/searchField"
android:layout_width="160dp"
android:layout_height="44dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="60dp"
android:background="#null"
android:cursorVisible="true"
android:ems="10"
android:textColor="#color/white"
android:textColorHighlight ="#ff0000"
android:textCursorDrawable="#null" >
</EditText>
the whole layout
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!--
As the main content view, the view below consumes the entire
space available using match_parent in both dimensions.
-->
<RelativeLayout
android:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff" >
<fragment
android:id="#+id/map"
android:name="com.sapientnitro.inhouse.drop.components.DRPCustomMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ImageButton
android:id="#+id/btn_center_local"
android:layout_width="44dp"
android:layout_height="44dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="50dp"
android:layout_marginRight="15dp"
android:background="#drawable/btn_center_on_local_up" />
<RelativeLayout
android:id="#+id/top_bar"
android:layout_width="match_parent"
android:layout_height="70dp"
android:background="#ddffffff" >
<ImageButton
android:id="#+id/btn_menu"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="10dp"
android:layout_marginRight="12dp"
android:layout_toLeftOf="#+id/btn_search"
android:background="#drawable/btn_menu_up" />
<ImageButton
android:id="#+id/btn_create"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="10dp"
android:layout_marginLeft="12dp"
android:layout_toRightOf="#+id/btn_search"
android:background="#drawable/btn_create_up" />
<ImageButton
android:id="#+id/btn_search"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
android:background="#drawable/btn_search_up" />
</RelativeLayout>
<LinearLayout
android:id="#+id/search"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ddffffff"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/search_bar"
android:layout_width="match_parent"
android:layout_height="70dp"
android:background="#dd00cccb" >
<ImageView
android:id="#+id/searchBox"
android:layout_width="238dp"
android:layout_height="44dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:src="#drawable/search_field" />
<ImageView
android:id="#+id/clear"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="220dp"
android:src="#drawable/btn_clear_field" />
<EditText
android:id="#+id/searchField"
android:layout_width="160dp"
android:layout_height="44dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="60dp"
android:background="#null"
android:cursorVisible="true"
android:ems="10"
android:textColor="#color/white"
android:textColorHighlight ="#color/white"
android:textCursorDrawable="#null" >
</EditText>
<TextView
android:id="#+id/cancelBTN"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="16dp"
android:textColor="#color/white"
android:textSize="22dp"
android:text="#string/cancel" />
</RelativeLayout>
<ScrollView
android:id="#+id/search_results_container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:paddingTop="2dp"
android:scrollbars="none" >
<LinearLayout
android:id="#+id/search_results_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/header_artists"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#dd00cccb" />
<HorizontalScrollView
android:id="#+id/results_artists"
android:layout_width="match_parent"
android:layout_height="150dp" />
<RelativeLayout
android:id="#+id/header_followers"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#dd00cccb" />
<HorizontalScrollView
android:id="#+id/results_followers"
android:layout_width="match_parent"
android:layout_height="150dp" />
<RelativeLayout
android:id="#+id/header_places"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#dd00cccb" />
<HorizontalScrollView
android:id="#+id/results_places"
android:layout_width="match_parent"
android:layout_height="150dp" />
</LinearLayout>
</ScrollView>
</LinearLayout>
</RelativeLayout>
<ListView
android:id="#+id/left_drawer"
android:layout_width="255dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#dd00cccb"
android:choiceMode="singleChoice"
android:divider="#android:color/transparent"
android:dividerHeight="0dp"
android:listSelector="#drawable/selector_transparent" />
<ListView
android:id="#+id/right_drawer"
android:layout_width="255dp"
android:layout_height="match_parent"
android:layout_gravity="end"
android:background="#dd00cccb"
android:choiceMode="singleChoice"
android:divider="#android:color/transparent"
android:dividerHeight="0dp"
android:listSelector="#drawable/selector_transparent" />
</android.support.v4.widget.DrawerLayout>
I was able to change the highlight of my edit text by adding this line to my themes.xml file:
<item name="android:textColorHighlight">#color/m_highlight_blue</item>
Simple, just use TextHightLight Property in XML Mode
android:textColorHighlight="#ff0000"
or add this in your theme
<item name="android:textColorHighlight">"#ff0000"</item>
[Image attached here is because for a comment below]
and when i do, this is how it looks
And if you have to change the Marker handle then you should change
<item name="colorAccent">#color/edittext_handle_selection</item>
<item name="android:textColorHighlight">#color/edittext_selection</item>
In code:
et.setHighlightColor(ContextCompat.getColor(getContext(), R.color.highlight));
You should use android:textColorHighlight in the EditText element in you layout xml file
In material design you will get the default ascent color in style so the all text selection and other theme would be according to that color. You can change this ascent color in following way -
Go to the style.xml and change the following color -
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorAccent">#color/colorAccent</item> // Replace this color with your own choice
</style>
you should use a selector to change text colors`:
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Pressed State -->
<item android:state_pressed="true"
android:color="#FF0000" />
<!-- Focused State -->
<item android:state_focused="true"
android:color="#FF0000" />
<!-- Default State -->
<item android:color="#FFFFFF" />
And then set your textColor property to #drawable/selector_name
use this code,might be its help you
android:textColorHighlight="your color code"
well there's a simpler way to do it...I was here to look for an answer, but im answering my own answer.
If you go to the attractions place go all the way down to the letter T and there should be an TextColorHighlight but if you don't see it the there should be ones
that aren't fully shown so go hover over them and then the full word will show
the showed be little color icons beside them you should press them and select your color. And then go to your code and enter TextColorHighlight Press Tab and then enter the name of the color, then run it!
Hope that this worked out for you, sorry I couldn't add any pictures of how'd it would of looked. Oh and maybe you're wondering why didn't it automatically do that then have me do it? Now im wondering that too, ill try to see what i can do