This is my EditText's selection mode style.
As you can see it's texts are not completely visible.
This is my styles.xml file:
<style name="MyApp" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primaryDark</item>
<item name="colorOnPrimary">#color/onPrimary</item>
<item name="colorSecondary">#color/secondary</item>
<item name="colorSecondaryVariant">#color/secondaryLight</item>
<item name="colorOnSecondary">#color/onSecondary</item>
<item name="colorError">#color/error</item>
<item name="colorOnError">#color/onError</item>
<item name="colorSurface">#color/surface</item>
<item name="android:textViewStyle">#style/DefaultTextStyle</item>
<item name="buttonStyle">#style/DefaultButtonStyle</item>
<item name="materialButtonStyle">#style/DefaultButtonStyle</item>
<item name="android:textColorPrimary">#color/enabledColor</item>
<item name="bottomSheetDialogTheme">#style/BottomSheetTheme</item>
<item name="textAppearanceBody1">#style/BodyAppearance</item>
<item name="textAppearanceSubtitle1">#style/Subtitle1Appearance</item>
<item name="textAppearanceSubtitle2">#style/Subtitle2Appearance</item>
<item name="textAppearanceButton">#style/ButtonAppearance</item>
<item name="textAppearanceHeadline1">#style/Headline1</item>
<item name="textAppearanceCaption">#style/Caption</item>
<item name="popupMenuStyle">#style/PopupMenuStyle</item>
<item name="transparentPrimaryColor">#color/transparentPrimary</item>
<item name="colorOnSurface">#color/onSurface</item>
<item name="windowActionModeOverlay">true</item>
<item name="windowNoTitle">true</item>
<item name="actionModeBackground">?attr/colorSecondary</item>
<item name="actionBarTheme">#style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
<item name="android:popupWindowStyle">#style/PopupWindodwStyle</item>
</style>
I found out that deleting textAppearanceButton attribute somehow fixes the problem. This is how the value of textAppearanceButton look like:
<style name="ButtonAppearance" parent="MyApp">
<item name="fontFamily">#font/iransans_bold</item>
<item name="android:textSize">14sp</item>
</style>
I cannot delete that attribute because I've used it throughout my application. Does anyone know why this problem happens? Thanks.
Related
Here is a dialog, how to change this color (unchecked)?
I try to set style but not work:
<style name="ThemeMyAppDialogAlertDay"
parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog">
<item name="colorPrimary">#color/color_secondary</item>
<item name="colorPrimaryVariant">#color/color_primary_variant</item>
<item name="colorOnPrimary">#color/color_secondary</item>
<item name="colorSecondary">#color/color_secondary</item>
<item name="colorAccent">#color/color_error</item>
</style>
You can use:
<style name="ThemeMyAppDialogAlertDay"
parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog">
<item name="colorSecondary">#color/selected</item> <!-- selected -->
<item name="colorControlNormal">#color/unselected</item> <!-- unselected -->
</style>
Try this , It should help
<style name="materialDiaog" parent="MaterialAlertDialog.MaterialComponents">
<item name="buttonTint">#color/colorPrimary</item>
<item name="colorPrimary">#color/color_secondary</item>
<item name="colorPrimaryVariant">#color/color_primary_variant</item>
<item name="colorOnPrimary">#color/color_secondary</item>
<item name="colorSecondary">#color/color_secondary</item>
<item name="colorAccent">#color/color_error</item>
</style>
<style name="AppTheme" parent="{set your parent theme here}">
<item name="materialAlertDialogTheme">#style/materialDiaog</item>
</style>
I have this Theme,
<style name="AppTheme" parent="#style/AppBaseTheme">
<item name="android:buttonStyle">#style/MyButtonStyle</item>
</style>
I need to define another style for a button (called MyButtonStyleDealer).
Using the following code I get error android:buttonStyle has been already defined.
<style name="AppTheme" parent="#style/AppBaseTheme">
<item name="android:buttonStyle">#style/MyButtonStyle</item>
<item name="android:buttonStyle">#style/MyButtonStyleDealer</item>
</style>
I would like to know if it possible define a second style for the button and how to apply it to the View.
If got your question correctly, you can add inside your style file another entry for the button
<style name="MyNotClickableButtonStyle">
<item name="android:background">#drawable/my_button_background</item>
<item name="android:clickable">false</item>
</style>
and inside your layout,
<Button
style="#style/MyNotClickableButtonStyle"
You only can define one android:buttonStyle. If you want to change only this the button style has to add another style.
Another properties can be used if you want but only once.
For instance:
<style name="GlobalAppTheme" parent="Theme.Sherlock.Light">
<item name="android:actionBarStyle">#style/ActionBar</item>
<item name="actionBarStyle">#style/ActionBar</item>
<item name="android:editTextStyle">#style/GlobalTextView</item>
<item name="android:textColor">#color/text_gray</item>
<item name="android:checkboxStyle">#style/CheckBox</item>
<item name="android:radioButtonStyle">#style/RadioButton</item>
<item name="android:buttonStyle">#style/Button</item>
<item name="android:textSize">14sp</item>
<item name="android:actionBarItemBackground">#android:color/transparent</item>
<item name="actionBarItemBackground">#android:color/transparent</item>
<item name="android:alertDialogStyle">#style/Theme.Sherlock.Light.Dialog</item>
</style>
<style name="GlobalAppTheme2" parent="Theme.Sherlock.Light">
<item name="android:actionBarStyle">#style/ActionBar</item>
<item name="actionBarStyle">#style/ActionBar</item>
<item name="android:editTextStyle">#style/GlobalTextView</item>
<item name="android:textColor">#color/text_gray</item>
<item name="android:checkboxStyle">#style/CheckBox</item>
<item name="android:radioButtonStyle">#style/RadioButton</item>
<item name="android:buttonStyle">#style/Button</item>
<item name="android:textSize">14sp</item>
<item name="android:actionBarItemBackground">#android:color/transparent</item>
<item name="actionBarItemBackground">#android:color/transparent</item>
<item name="android:alertDialogStyle">#style/Theme.Sherlock.Light.Dialog</item>
</style>
You can set sepecific styles like this:
<Button
android:id="#+id/button_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_send"
android:onClick="sendMessage"
style="?android:attr/MyButtonStyleDealer" />
Option Menu show incorrectly on Custom Style map
The problem raised on an application in android
I have a custom theme on my app. The problem is that the option menu shows incorrectly ,so the option menu shows cut of on the screen.
I wondering why could happen?
This is my style file xml
<style name="AppTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:typeface">normal</item>
<item name="android:typeface">sans</item>
<item name="android:typeface">serif</item>
<item name="android:typeface">monospace</item>
<item name="android:actionBarItemBackground">#drawable/selectable_background_example</item>
<item name="android:popupMenuStyle">#style/PopupMenu.Example</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Example</item>
<item name="android:actionBarTabStyle">#style/ActionBarTabStyle.Example</item>
<item name="android:actionDropDownStyle">#style/DropDownNav.Example</item>
<item name="android:actionBarStyle">#style/ActionBar.Solid.Example</item>
<item name="android:actionModeBackground">#drawable/cab_background_top_example</item>
<item name="android:actionModeSplitBackground">#drawable/cab_background_bottom_example</item>
<item name="android:actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Example</item>
</style>
<style name="ActionBar.Solid.Example" parent="#android:style/Widget.Holo.Light.ActionBar.Solid">
<item name="android:background">#drawable/ab_solid_example</item>
<item name="android:backgroundStacked">#drawable/ab_stacked_solid_example</item>
<item name="android:backgroundSplit">#drawable/ab_bottom_solid_example</item>
<item name="android:progressBarStyle">#style/ProgressBar.Example</item>
</style>
<style name="ActionBar.Transparent.Example" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#drawable/ab_transparent_example</item>
<item name="android:progressBarStyle">#style/ProgressBar.Example</item>
</style>
<style name="PopupMenu.Example" parent="#android:style/Widget.Holo.Light.ListPopupWindow">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_example</item>
</style>
<style name="DropDownListView.Example" parent="#android:style/Widget.Holo.Light.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_example</item>
</style>
<style name="ActionBarTabStyle.Example" parent="#android:style/Widget.Holo.Light.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator_ab_example</item>
</style>
<style name="DropDownNav.Example" parent="#android:style/Widget.Holo.Light.Spinner">
<item name="android:background">#drawable/spinner_background_ab_example</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_example</item>
<item name="android:dropDownSelector">#drawable/selectable_background_example</item>
</style>
<style name="ProgressBar.Example" parent="#android:style/Widget.Holo.Light.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/progress_horizontal_example</item>
</style>
<style name="ActionButton.CloseMode.Example" parent="#android:style/Widget.Holo.Light.ActionButton.CloseMode">
<item name="android:background">#drawable/btn_cab_done_example</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Example.Widget" parent="#android:style/Theme.Holo">
<item name="android:popupMenuStyle">#style/PopupMenu.Example</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Example</item>
</style>
For any ones that have this same trouble, the solution , in my case , was solved by added this line in the manifest file.
<supports-screens
android:anyDensity="true" />
I have tried a lot of changes but I never seem to get rid of this error, I don't have any library imported because I lost all data.
<style name="TextAppearance.AppCompat.Light.Widget.PopupMenu.Large" parent="#style/TextAppearance.AppCompat.Light.Base.Widget.PopupMenu.Large" />
<style name="TextAppearance.AppCompat.Light.Widget.PopupMenu.Small" parent="#style/TextAppearance.AppCompat.Light.Base.Widget.PopupMenu.Small" />
<style name="TextAppearance.AppCompat.SearchResult.Title" parent="#style/TextAppearance.AppCompat.Base.SearchResult.Title" />
<style name="TextAppearance.AppCompat.SearchResult.Subtitle" parent="#style/TextAppearance.AppCompat.Base.SearchResult.Subtitle" />
<style name="TextAppearance.AppCompat.Light.SearchResult.Title" parent="#style/TextAppearance.AppCompat.Light.Base.SearchResult.Title" />
<style name="TextAppearance.AppCompat.Light.SearchResult.Subtitle" parent="#style/TextAppearance.AppCompat.Light.Base.SearchResult.Subtitle" />
<style name="Widget.AppCompat.AutoCompleteTextView" parent="#style/Widget.AppCompat.Base.AutoCompleteTextView" />
<style name="Widget.AppCompat.Light.AutoCompleteTextView" parent="#style/Widget.AppCompat.Light.Base.AutoCompleteTextView" />
<style name="Widget.AppCompat.ActivityChooserView" parent="#style/Widget.AppCompat.Base.ActivityChooserView" />
<style name="Widget.AppCompat.Light.ActivityChooserView" parent="#style/Widget.AppCompat.Light.Base.ActivityChooserView" />
<style name="Widget.AppCompat.Base.ActionBar">
<item name="actionOverflowButtonStyle">#style/Widget.AppCompat.ActionButton.Overflow</item>
<item name="actionButtonStyle">#style/Widget.AppCompat.ActionButton</item>
<item name="height">?actionBarSize</item>
<item name="displayOptions">useLogo|showHome|showTitle</item>
<item name="titleTextStyle">#style/TextAppearance.AppCompat.Widget.ActionBar.Title</item>
<item name="subtitleTextStyle">#style/TextAppearance.AppCompat.Widget.ActionBar.Subtitle</item>
<item name="divider">?dividerVertical</item>
<item name="background">#drawable/abc_ab_transparent_dark_holo</item>
<item name="backgroundStacked">#drawable/abc_ab_stacked_transparent_dark_holo</item>
<item name="backgroundSplit">#drawable/abc_ab_bottom_transparent_dark_holo</item>
<item name="homeLayout">#layout/abc_action_bar_home</item>
<item name="progressBarStyle">#style/Widget.AppCompat.ProgressBar.Horizontal</item>
<item name="indeterminateProgressStyle">#style/Widget.AppCompat.ProgressBar</item>
</style>
<style name="Widget.AppCompat.Light.Base.ActionBar" parent="#style/Widget.AppCompat.Base.ActionBar">
<item name="actionOverflowButtonStyle">#style/Widget.AppCompat.Light.ActionButton.Overflow</item>
<item name="actionButtonStyle">#style/Widget.AppCompat.Light.ActionButton</item>
<item name="background">#drawable/abc_ab_transparent_light_holo</item>
<item name="backgroundStacked">#drawable/abc_ab_stacked_transparent_light_holo</item>
<item name="backgroundSplit">#drawable/abc_ab_bottom_transparent_light_holo</item>
<item name="progressBarStyle">#style/Widget.AppCompat.ProgressBar.Horizontal</item>
<item name="indeterminateProgressStyle">#style/Widget.AppCompat.ProgressBar</item>
</style>
<style name="Widget.AppCompat.Base.ActionBar.Solid" parent="#style/Widget.AppCompat.Base.ActionBar">
<item name="background">#drawable/abc_ab_solid_dark_holo</item>
<item name="backgroundStacked">#drawable/abc_ab_stacked_solid_dark_holo</item>
<item name="backgroundSplit">#drawable/abc_ab_bottom_solid_dark_holo</item>
</style>
<style name="Widget.AppCompat.Light.Base.ActionBar.Solid" parent="#style/Widget.AppCompat.Light.Base.ActionBar">
<item name="background">#drawable/abc_ab_solid_light_holo</item>
<item name="backgroundStacked">#drawable/abc_ab_stacked_solid_light_holo</item>
<item name="backgroundSplit">#drawable/abc_ab_bottom_solid_light_holo</item>
</style>
<style name="Widget.AppCompat.Light.Base.ActionBar.Solid.Inverse" parent="#style/Widget.AppCompat.Base.ActionBar.Solid">
<item name="actionOverflowButtonStyle">#style/Widget.AppCompat.ActionButton.Overflow</item>
<item name="actionButtonStyle">#style/Widget.AppCompat.ActionButton</item>
<item name="titleTextStyle">#style/TextAppearance.AppCompat.Widget.ActionBar.Title.Inverse</item>
<item name="subtitleTextStyle">#style/TextAppearance.AppCompat.Widget.ActionBar.Subtitle.Inverse</item>
</style>
<style name="Widget.AppCompat.Base.ActionButton">
<item name="android:gravity">center</item>
<item name="android:background">?actionBarItemBackground</item>
<item name="android:paddingLeft">12.0dip</item>
<item name="android:paddingRight">12.0dip</item>
<item name="android:minWidth">#dimen/abc_action_button_min_width</item>
<item name="android:minHeight">?actionBarSize</item>
<item name="android:maxLines">2</item>
<item name="textAllCaps">#bool/abc_config_actionMenuItemAllCaps</item>
</style>
The errors occurs in these follow lines
<style name="Widget.AppCompat.Base.ActionBar">
And this
<style name="Theme.AppCompat.Base.CompactMenu">
Please help me out, I'm a newbie so step by step is highly appreciated!
I need to extract attribute values from <Item Name="CanonicalSmiles"> from following XML file (part is shown) ?
I tried getElementsByTagName("Item").item(12).getTextContent()); But for different <DocSum>s item(i) is different (ie not 12 always!)
How do I do this??
<?xml version="1.0"?>
<!DOCTYPE eSummaryResult PUBLIC "-//NLM//DTD eSummaryResult, 29 October 2004//EN" "http://www.ncbi.nlm.nih.gov/entrez/query/DTD/eSummary_041029.dtd">
<eSummaryResult>
<DocSum>
<Id>53359352</Id>
<Item Name="CID" Type="Integer">53359352</Item>
<Item Name="SourceNameList" Type="List"></Item>
<Item Name="SourceIDList" Type="List"></Item>
<Item Name="SourceCategoryList" Type="List">
<Item Name="string" Type="String">Journal Publishers</Item>
</Item>
<Item Name="CreateDate" Type="Date">2011/09/19 00:00</Item>
<Item Name="SynonymList" Type="List"></Item>
<Item Name="MeSHHeadingList" Type="List"></Item>
<Item Name="MeSHTermList" Type="List"></Item>
<Item Name="PharmActionList" Type="List"></Item>
<Item Name="CommentList" Type="List"></Item>
<Item Name="IUPACName" Type="String">2-hydroxy-6-[2-(4-hydroxyphenyl)-2-oxoethyl]benzoic acid</Item>
<Item Name="CanonicalSmiles" Type="String">C1=CC(=C(C(=C1)O)C(=O)O)CC(=O)C2=CC=C(C=C2)O</Item>
<Item Name="RotatableBondCount" Type="Integer">4</Item>
<Item Name="MolecularFormula" Type="String">C15H12O5</Item>
<Item Name="MolecularWeight" Type="String">272.252780</Item>
<Item Name="TotalFormalCharge" Type="Integer">0</Item>
<Item Name="XLogP" Type="String"></Item>
<Item Name="HydrogenBondDonorCount" Type="Integer">3</Item>
<Item Name="HydrogenBondAcceptorCount" Type="Integer">5</Item>
<Item Name="Complexity" Type="String">359.000000</Item>
<Item Name="HeavyAtomCount" Type="Integer">20</Item>
<Item Name="AtomChiralCount" Type="Integer">0</Item>
<Item Name="AtomChiralDefCount" Type="Integer">0</Item>
<Item Name="AtomChiralUndefCount" Type="Integer">0</Item>
<Item Name="BondChiralCount" Type="Integer">0</Item>
<Item Name="BondChiralDefCount" Type="Integer">0</Item>
<Item Name="BondChiralUndefCount" Type="Integer">0</Item>
<Item Name="IsotopeAtomCount" Type="Integer">0</Item>
<Item Name="CovalentUnitCount" Type="Integer">1</Item>
<Item Name="TautomerCount" Type="Integer">67</Item>
<Item Name="SubstanceIDList" Type="List"></Item>
<Item Name="TPSA" Type="String">94.8</Item>
<Item Name="AssaySourceNameList" Type="List"></Item>
<Item Name="MinAC" Type="String"></Item>
<Item Name="MaxAC" Type="String"></Item>
<Item Name="MinTC" Type="String"></Item>
<Item Name="MaxTC" Type="String"></Item>
<Item Name="ActiveAidCount" Type="Integer">0</Item>
<Item Name="InactiveAidCount" Type="Integer">0</Item>
<Item Name="TotalAidCount" Type="Integer">0</Item>
<Item Name="InChIKey" Type="String">YIGHIFUVVSYMFG-UHFFFAOYSA-N</Item>
<Item Name="InChI" Type="String">InChI=1S/C15H12O5/c16-11-6-4-9(5-7-11)13(18)8-10-2-1-3-12(17)14(10)15(19)20/h1-7,16-17H,8H2,(H,19,20)</Item>
</DocSum>
<DocSum>
<Id>53346823</Id>
<Item Name="CID" Type="Integer">53346823</Item>
<Item Name="SourceNameList" Type="List"></Item>
<Item Name="SourceIDList" Type="List"></Item>
<Item Name="SourceCategoryList" Type="List">
<Item Name="string" Type="String">Biological Properties</Item>
</Item>
<Item Name="CreateDate" Type="Date">2011/09/01 00:00</Item>
<Item Name="SynonymList" Type="List">
<Item Name="string" Type="String">HMS2478O14</Item>
</Item>
<Item Name="MeSHHeadingList" Type="List"></Item>
<Item Name="MeSHTermList" Type="List"></Item>
<Item Name="PharmActionList" Type="List"></Item>
<Item Name="CommentList" Type="List">
<Item Name="string" Type="String">Asinex Ltd.:BAS 02768155</Item>
</Item>
<Item Name="IUPACName" Type="String">ethyl 3-amino-3-(1,3-benzodioxol-5-yl)propanoate chloride</Item>
<Item Name="CanonicalSmiles" Type="String">CCOC(=O)CC(C1=CC2=C(C=C1)OCO2)N.[Cl-]</Item>
<Item Name="RotatableBondCount" Type="Integer">5</Item>
<Item Name="MolecularFormula" Type="String">C12H15ClNO4-</Item>
<Item Name="MolecularWeight" Type="String">272.704800</Item>
<Item Name="TotalFormalCharge" Type="Integer">-1</Item>
<Item Name="XLogP" Type="String"></Item>
<Item Name="HydrogenBondDonorCount" Type="Integer">1</Item>
<Item Name="HydrogenBondAcceptorCount" Type="Integer">6</Item>
<Item Name="Complexity" Type="String">271.000000</Item>
<Item Name="HeavyAtomCount" Type="Integer">18</Item>
<Item Name="AtomChiralCount" Type="Integer">1</Item>
<Item Name="AtomChiralDefCount" Type="Integer">0</Item>
<Item Name="AtomChiralUndefCount" Type="Integer">1</Item>
<Item Name="BondChiralCount" Type="Integer">0</Item>
<Item Name="BondChiralDefCount" Type="Integer">0</Item>
<Item Name="BondChiralUndefCount" Type="Integer">0</Item>
<Item Name="IsotopeAtomCount" Type="Integer">0</Item>
<Item Name="CovalentUnitCount" Type="Integer">2</Item>
<Item Name="TautomerCount" Type="Integer">1</Item>
<Item Name="SubstanceIDList" Type="List"></Item>
<Item Name="TPSA" Type="String">70.8</Item>
<Item Name="AssaySourceNameList" Type="List"></Item>
<Item Name="MinAC" Type="String"></Item>
<Item Name="MaxAC" Type="String"></Item>
<Item Name="MinTC" Type="String"></Item>
<Item Name="MaxTC" Type="String"></Item>
<Item Name="ActiveAidCount" Type="Integer">0</Item>
<Item Name="InactiveAidCount" Type="Integer">0</Item>
<Item Name="TotalAidCount" Type="Integer">0</Item>
<Item Name="InChIKey" Type="String">NKQHQIJWIYNEIX-UHFFFAOYSA-M</Item>
<Item Name="InChI" Type="String">InChI=1S/C12H15NO4.ClH/c1-2-15-12(14)6-9(13)8-3-4-10-11(5-8)17-7-16-10;/h3-5,9H,2,6-7,13H2,1H3;1H/p-1</Item>
</DocSum>
For what you're doing, XPath is likely easier than DOM. See this Java XPath tutorial.
XPathFactory xpf = XPathFactory.newInstance();
XPath xp = xpf.newXPath();
XPathExpression xe = xp.compile("//DocSum/Item[#Name='CanonicalSmiles']/text()");
NodeList nodes = (NodeList)xe.evaluate(yourdom, XPathConstants.NODESET);
As others have pointed out, XPath is the standard way to go. If you're using a tool like jOOX, writing XPath is even simpler:
String text = $(document).xpath("//DocSum/Item[#Name='CanonicalSmiles']").text();
With jOOX, you don't need to use XPath, however. You could also use jOOX's jQuery-like API directly, for instance using filters:
String text = $(document).find("Item")
.filter(attr("Name", "CanonicalSmiles"))
.text();
Or by using CSS-style selectors:
String text = $(document).find("Item[Name='CanonicalSmiles']").text();
As I see, the problem of parser each time reading XML elements in different order remained still unanswered.
XML has not any order of elements. You can't wait that the element read as num. 12 today will be num. 12 tomorrow. The only way to number your elements is go give them numbers explicitely.
<Item Name="TotalFormalCharge" Type="Integer">-1</Item>
will become:
<Item Name="TotalFormalCharge" Num=6 Type="Integer">-1</Item>
And you can get it by the attribute value.