I have created a custom toolbar which has a spinner. I am trying to set a custom colour for the spinner arrow - currently the default is white, but it's not working, any ideas?
This is my Toolbar layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/newToolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/colorPrimary"
android:elevation="0dp"
android:windowContentOverlay="#null"
android:orientation="horizontal">
<ImageView
android:id="#+id/strLogo"
android:layout_width="45dp"
android:layout_height="40dp"
android:layout_marginTop="13dp"
android:scaleType="fitCenter"
android:visibility="gone"
android:background="#ffffff"
android:src="#mipmap/logo"/>
<TextView
android:id="#+id/updateName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left|center_vertical"
android:layout_toRightOf="#+id/strLogo"
android:layout_centerVertical="true"
android:text="Test"
android:visibility="visible"
android:textColor="#ffffff"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="normal" />
<Spinner
android:id="#+id/spinner_nav"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
style="#style/customSpinnerTheme"
android:visibility="visible"/>
</RelativeLayout>
This my style xml for the spinner:
<style name="customSpinnerTheme" parent="ThemeOverlay.AppCompat">
<item name="colorControlActivated">#FFFFFF</item>
<item name="colorControlHighlight">#FFFFFF</item>
</style>
You can add this type of style in your spinner style and add your colors which you want to use as your drawable:
<style name="SpinnerAppTheme" parent="android:Widget.Spinner">
<item name="android:background">#drawable/apptheme_spinner_background_holo_light</item>
<item name="android:dropDownSelector">#drawable/apptheme_list_selector_holo_light</item>
</style>
Related
So I've been struggling centring this button in my View for about 3 hours I've gave up and came here to ask for some advice from more experienced android developers.
For now it looks like this.
I would like to look something like this
My view looks like this in code:
<RelativeLayout
android:id="#+id/receptionLineAddQuantityAndSeries"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:paddingBottom="#dimen/padding_layout">
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_above="#+id/layoutQntInput"
local:MvxBind="Visibility Article.SeriesType, Converter=Visibility;">
<Mvx.MvxImageView
android:id="#+id/articleSeriesImage"
android:src="#drawable/ic_list_white_48dp"
android:layout_width="wrap_content"
android:scaleType="center"
android:paddingRight="#dimen/padding_layout"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_alignParentRight="true"
android:background="#drawable/button_border"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp" />
<RelativeLayout
android:id="#+id/layoutInputSeries"
android:paddingLeft="#dimen/padding_layout"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginRight="58dp">
<TextView
android:id="#+id/suppliersSearchInputLabelCode"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_alignParentTop="true"
style="#style/ExtendProTheme.EditTextLabel"
local:MvxBind="Visibility Article.SeriesType, Converter=Visibility; Text Article.SeriesType, Converter=ArticleSeriesTypeToLabel;" />
<CC.CustomEditText
android:id="#+id/inventoryIdentifyArticleEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:theme="#style/ExtendProTheme"
android:maxLength="20"
android:layout_below="#+id/suppliersSearchInputLabelCode"
style="#style/ExtendProTheme.EditText"
local:MvxBind="Text Article.SeriesName, Mode=TwoWay; Error Errors['SeriesName']; Visibility Article.SeriesType, Converter=Visibility; Hint Article.SeriesType, Converter=ArticleSeriesTypeToHint; EnterCommand GetSeriesTotalQuantityCommand; FocusChangeCommand GetSeriesTotalQuantityCommand;" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
What i've tried so far is all the combination of
android:scaleType = fitXY, fitCenter, center, matrix
fixed widths for the ImageView, no results...
Any help would be nice.
I've tried all the answers below and they still didn't show as expected. I found a version that looks close to what i need .
<Mvx.MvxImageView
android:layout_width="48dp"
android:layout_height="match_parent"
android:src="#drawable/ic_list_white_48dp"
android:id="#+id/articleSeriesImage"
style="#style/ExtendProTheme.ListButtonSeriesStyle">
<style name="ExtendProTheme.ListButtonSeriesStyle">
<item name="android:scaleType">matrix</item>
<item name="android:paddingRight">#dimen/padding_layout</item>
<item name="android:layout_marginLeft">8dp</item>
<item name="android:layout_marginRight">8dp</item>
<item name="android:layout_marginTop">8dp</item>
<item name="android:background">#drawable/button_border</item>
<item name="android:layout_alignParentRight">true</item>
<item name="android:layout_gravity">center</item>
</style>
try this one :)
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:id="#+id/receptionLineAddQuantityAndSeries">
<Mvx.MvxImageView
android:id="#+id/articleSeriesImage"
android:src="#drawable/ic_list_white_48dp"
android:layout_width="60dp"
android:layout_height="match_parent"
android:scaleType="center"
android:paddingRight="#dimen/padding_layout"
android:gravity="center"
android:layout_alignParentRight="true"
android:background="#drawable/button_border"
android:layout_marginRight="15dp"
android:layout_centerVertical="true"/>
<TextView
android:id="#+id/suppliersSearchInputLabelCode"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
style="#style/ExtendProTheme.EditTextLabel"
local:MvxBind="Visibility Article.SeriesType, Converter=Visibility; Text Article.SeriesType, Converter=ArticleSeriesTypeToLabel;" />
<CC.CustomEditText
android:id="#+id/inventoryIdentifyArticleEditText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:theme="#style/ExtendProTheme"
android:maxLength="20"
android:layout_below="#+id/suppliersSearchInputLabelCode"
android:layout_toLeftOf="#+id/articleSeriesImage"
style="#style/ExtendProTheme.EditText"
local:MvxBind="Text Article.SeriesName, Mode=TwoWay; Error Errors['SeriesName']; Visibility Article.SeriesType, Converter=Visibility; Hint Article.SeriesType, Converter=ArticleSeriesTypeToHint; EnterCommand GetSeriesTotalQuantityCommand; FocusChangeCommand GetSeriesTotalQuantityCommand;" />
</RelativeLayout>
try this ,check for syntax
<RelativeLayout>
<TextView
id=#+id/yourtxtv
/>
<ImageView
android:layout_alignBaseline
android:align_right_to="#+id/yourtxtv"
android:margin_right=xxxx(put the value u want to put)
/>
</RelativeLayout>
This is what I tried and found:
<RelativeLayout
android:id="#+id/receptionLineAddQuantityAndSeries"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
<ImageView
android:id="#+id/articleSeriesImage"
android:src="#drawable/ic_android"
android:background="#color/blue"
android:layout_width="wrap_content"
android:scaleType="center"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_alignParentRight="true"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp" />
<RelativeLayout
android:id="#+id/layoutInputSeries"
android:paddingLeft="64dp"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginRight="58dp">
<TextView
android:id="#+id/suppliersSearchInputLabelCode"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="sn"
android:layout_alignParentTop="true"/>
<EditText
android:id="#+id/inventoryIdentifyArticleEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:theme="#style/ExtendProTheme"
android:maxLength="20"
android:layout_below="#+id/suppliersSearchInputLabelCode"/>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
The solution was
<Mvx.MvxImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:src="#drawable/ic_list_white_48dp"
android:id="#+id/articleSeriesImage"
style="#style/ExtendProTheme.ListButtonSeriesStyle">
<style name="ExtendProTheme.ListButtonSeriesStyle">
<item name="android:scaleType">matrix</item>
<item name="android:paddingRight">#dimen/padding_layout</item>
<item name="android:layout_marginLeft">8dp</item>
<item name="android:layout_marginRight">8dp</item>
<item name="android:layout_marginTop">8dp</item>
<item name="android:background">#drawable/button_border</item>
<item name="android:layout_alignParentRight">true</item>
<item name="android:layout_gravity">center</item>
</style>
It's the only way it worked . Thanks all for ideas.
I have the following layout for my custom log in dialog
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="#dimen/padding_large">
<ImageButton android:src="#drawable/ic_settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/dialog.login.settings"
android:padding="#dimen/margin_medium" />
<TextView android:text="#string/dialog.login.text.user_name"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<EditText android:id="#+id/dialog.login.user_name"
android:layout_width="match_parent"
android:gravity="center"
android:ems="20"
android:layout_height="wrap_content"
android:inputType="text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView android:text="#string/dialog.login.text.password"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<EditText android:id="#+id/dialog.login.password"
android:layout_width="match_parent"
android:gravity="center"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:textAppearance="?android:attr/textAppearanceMedium" />
<CheckBox android:id="#+id/dialog.login.show_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/dialog.login.check.show_password"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_margin="#dimen/margin_medium"
android:checked="false" />
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button android:id="#+id/dialog.login.cancel"
android:drawableStart="#drawable/ic_exit_black"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginEnd="#dimen/margin_medium"
android:text="#string/dialog.login.button.cancel" />
<Button android:id="#+id/dialog.login.connect"
android:text="#string/dialog.login.button.connect"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_marginStart="#dimen/margin_medium"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
when I create the dialog and setcontentview the width of the dialog becomes equal to that of the image button on the first row
if I remove that , it becomes the size of the EditText (dialog.login.user_name) whose ems is 20
when I make the dialog's constructor call the base dialog constructor with a theme of R.style.Theme.Material.Dialog it does get the correct (about 3/4 of the screen) but the problem is that it ignores my primary and accent colours (which is normal)
Is there a way to have the dialog have the Theme.Material.Dialog size but still keep my own primary/accent colours?
thanks in advance for any help you can provide
After a lot of searching it seems that the solution is to actually replace the dialogTheme attribute of my main theme, so the solution was:
<style name="app.theme"
parent="android:Theme.Material.Light.NoActionBar.Fullscreen">
<item name="android:dialogTheme">#style/app.dialog</item>
......
</style>
<style name="app.dialog"
parent="android:Theme.Material.Light.Dialog">
<item name="android:colorPrimary">#color/primary</item>
<item name="android:colorPrimaryDark">#color/primary.dark</item>
<item name="android:colorAccent">#color/accent</item>
</style>
Not too sure how to word this but if you look at my picture below the blue of Victoria disappears off the screen but i'd like to to start a new line so you can clearly see the whole thing.
Heres my xml for for each list component. I have 5 textviews which are situated to the right of the preceding one, how can I pickup when one is too long for the line and move to another line?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/tube_stop_graphic1"
android:orientation="horizontal"
android:gravity="center_vertical|center_horizontal"
android:layout_width="25sp"
android:layout_height="25sp"
android:scaleType="fitXY"/>
<ImageView
android:id="#+id/tube_stop_graphic2"
android:orientation="horizontal"
android:gravity="center_vertical|center_horizontal"
android:layout_width="25sp"
android:layout_height="25sp"
android:scaleType="fitXY"
android:layout_below="#id/tube_stop_graphic1"/>
<ImageView
android:id="#+id/tube_stop_graphic3"
android:orientation="horizontal"
android:gravity="center_vertical|center_horizontal"
android:layout_width="25sp"
android:layout_height="25sp"
android:scaleType="fitXY"
android:layout_below="#id/tube_stop_graphic2"/>
<TextView
android:id="#+id/tube_stop_name"
android:orientation="horizontal"
android:paddingLeft="10px"
android:textSize="20sp"
android:text="BLABLA"
android:textStyle="normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/tube_stop_graphic1"/>
<TextView
android:id="#+id/tube_stop_distance"
android:orientation="horizontal"
android:layout_alignParentRight="true"
android:gravity="right|center"
android:paddingRight="10px"
android:text="BLABLA"
android:textSize="14sp"
android:textStyle="normal"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_toRightOf="#id/tube_stop_name"/>
<TextView
android:id="#+id/tube_line1"
style="#style/Tube_Stop_TextView"
android:text="Overgound"
android:layout_toRightOf="#id/tube_stop_graphic1"
android:layout_below="#id/tube_stop_name"/>
<TextView
android:id="#+id/tube_line2"
style="#style/Tube_Stop_TextView"
android:layout_toRightOf="#id/tube_line1"
android:layout_below="#id/tube_stop_name"/>
<TextView
android:id="#+id/tube_line3"
style="#style/Tube_Stop_TextView"
android:layout_toRightOf="#id/tube_line2"
android:layout_below="#id/tube_stop_name"/>
<TextView
android:id="#+id/tube_line4"
style="#style/Tube_Stop_TextView"
android:layout_toRightOf="#id/tube_line3"
android:layout_below="#id/tube_stop_name"/>
<TextView
android:id="#+id/tube_line5"
style="#style/Tube_Stop_TextView"
android:layout_toRightOf="#id/tube_line4"
android:layout_below="#id/tube_stop_name"/>
</RelativeLayout>
and the style for each of them
<style name="Tube_Stop_TextView">
<item name="android:gravity">center_vertical|center_horizontal</item>
<item name="android:paddingLeft">5sp</item>
<item name="android:paddingTop">5sp</item>
<item name="android:paddingBottom">5sp</item>
<item name="android:paddingRight">5sp</item>
<item name="android:textSize">10sp</item>
<item name="android:textStyle">normal</item>
<item name="android:background">#drawable/rounded_square</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:inputType">text</item>
</style>
It will be better if you wrap all your textviews in a gridview. Because your first TextView is having long text here. Gridview will push any view which is out of available width to a new row.
i want to create header in android with text and buttons like in iOS (Text in Cetner and Buttons on right and left side), i have tried but not useful at all,please guide me ... how can i make this one for my app
Try this. Make header.xml file and put below code in it and use it in any layout file using include .
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#drawable/titlebar"
android:gravity="center">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/back_button"
android:background="#android:color/transparent"
android:layout_marginLeft="5.0dip"
android:id="#+id/imageButtonBack"
android:contentDescription="#string/ui_image_home_description"/>
<TextView
android:id="#+id/textViewTitleBar"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
style="#style/TitleBarText"
android:singleLine="false"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/home_button"
android:background="#android:color/transparent"
android:layout_marginRight="5.0dip"
android:id="#+id/imageButtonHome"
android:contentDescription="#string/ui_image_home_description"/>
</LinearLayout>
Note : Add the below style to style.xml in res/values folder.
<style name="TitleBarText">
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">fill_parent</item>
<item name="android:layout_weight">1</item>
<item name="android:gravity">center_vertical</item>
<item name="android:textSize"> 17sp </item>
<item name="android:paddingLeft">12dip</item>
<item name="android:paddingRight">12dip</item>
<item name="android:textColor">#color/white</item>
<item name="android:singleLine">true</item>
<item name="android:ellipsize">end</item>
</style>
This is an easier one. You can try this:
<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" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#drawable/header">
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="Back" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="Next" />
</RelativeLayout>
</RelativeLayout>
I'm trying to manage my application style using a custom theme:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme.Styled" parent="Theme.Sherlock.Light.DarkActionBar">
<item name="actionBarStyle">#style/Widget.Styled.ActionBar</item>
<item name="actionBarTabStyle">#style/Widget.Sherlock.Light.ActionBar.TabView</item>
<item name="android:actionBarStyle">#style/Widget.Styled.ActionBar</item>
<item name="android:textViewStyle">#style/MyTextViewStyle</item>
</style>
<style name="Widget.Styled.ActionBar" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">
<item name="background">#drawable/background</item>
<item name="android:background">#drawable/background</item>
</style>
<style name="MyTextViewStyle" parent="#android:style/Widget.TextView">
<item name="android:textColor">#color/text</item>
</style>
</resources>
As you can see, I set the TextView default color to #color/text (#ff000000). This works OK in all the TextViews of my application except the ones in my custom list item layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/mov_concept"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="5dp"
android:layout_marginTop="2dp"
android:textSize="16dp"
android:textStyle="bold" />
<TextView
android:id="#+id/mov_category"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/mov_concept"
android:layout_marginLeft="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/mov_amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/mov_category"
android:layout_centerHorizontal="true"
android:layout_marginBottom="6dp"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/mov_period"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/mov_amount"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/mov_until"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/mov_period"
android:layout_alignBottom="#+id/mov_period"
android:layout_alignParentRight="true"
android:layout_marginBottom="2dp"
android:layout_marginRight="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/mov_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/mov_concept"
android:layout_alignBottom="#+id/mov_category"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:layout_marginTop="2dp" />
</RelativeLayout>
I don't know why this happens, thank you in advance.
I had the same problem because of using Application Context instead of Activity Context for ListAdapter. To fix the issue I changed my code from
MyAdapter adapter = new MyAdapter(getApplicationContext(), ...)
to
MyAdapter adapter = new MyAdapter(MyActivity.this, ...)
It's because you apply a android:textAppearance to your textviews which override the color of your style.