android-attributes

How to get android default attributes in a custom view

血红的双手。 提交于 2020-03-21 17:57:28
问题 I have created a simple custom view that contains a RelativeLayout and an EditText : <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <EditText android:id="@+id/edt_content" android:layout_width="match_parent" android:layout_height="wrap_content"/> </RelativeLayout> Also I have added some custom attributes in res/values/attrs.xml and I retrieve these attributes in my custom view constructor and

Manifest merger failed : Attribute application@appComponentFactory value=(androidx.core.app.CoreComponentFactory)

橙三吉。 提交于 2020-01-25 06:40:08
问题 Manifest merger failed : Attribute application@appComponentFactory value=(androidx.core.app.CoreComponentFactory) from [androidx.core:core:1.0.1] AndroidManifest.xml:22:18-86 is also present at [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 value=(android.support.v4.app.CoreComponentFactory). Suggestion: add 'tools:replace="android:appComponentFactory"' to element at AndroidManifest.xml:17:5-122:19 to override. org.gradle.api.tasks.TaskExecutionException: Execution

Error inflating class Button in Android

柔情痞子 提交于 2019-12-30 07:22:24
问题 I have an application with min sdk 16 up to 23. I want to use Material design as much as possible. It also has to be fullscreen app. AppCompat support library is included. Now I have Logon activity with some buttons: <Button android:id="@+id/act_logon_btn_logon" style="@style/ButtonDefault" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/act_logon_logon" /> Styles are as follows (values/styles.xml): <style name="Theme.AppCompat.Light.NoActionBar

Error inflating class Button in Android

蹲街弑〆低调 提交于 2019-12-30 07:22:08
问题 I have an application with min sdk 16 up to 23. I want to use Material design as much as possible. It also has to be fullscreen app. AppCompat support library is included. Now I have Logon activity with some buttons: <Button android:id="@+id/act_logon_btn_logon" style="@style/ButtonDefault" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/act_logon_logon" /> Styles are as follows (values/styles.xml): <style name="Theme.AppCompat.Light.NoActionBar

Android Resolving style properties and attributes?

荒凉一梦 提交于 2019-12-23 03:47:12
问题 My Android Application has a main Project Module that has the following declaration in the styles file. This Theme is used in the Manifest file on the "application" tag so all components within the "application" element have the same theme applied. <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.NoActionBar"> <item name="android:colorPrimary" tools:ignore="NewApi"> @color/light_black </item> <item name="colorPrimary">@color/light_black</item> <item name=

Why is this custom view attribute ignored?

随声附和 提交于 2019-12-12 03:46:39
问题 I am trying to define an attribute for any view using the Data Binding Library, as explained in this Android Developers post. To do so, the post says one first needs a layout with an enclosing <layout> tag: <?xml version="1.0" encoding="utf-8"?> <layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView

Android “?colorPrimary” vs “?attr/colorPrimary”?

大憨熊 提交于 2019-12-07 09:07:31
问题 I can't find any information about the differences between: android:textColor="?attr/colorPrimary" vs android:textColor="?colorPrimary" I have read that "?attr" means attribute value specified in the current theme, but without "attr" it gives the same result (=color defined in my theme). It behaves similar with other attributes? For example: Does android:background="?attr/selectableItemBackground" equals android:background="?selectableItemBackground" ? Here it's told that it differs. Thanks

Android “?colorPrimary” vs “?attr/colorPrimary”?

泄露秘密 提交于 2019-12-05 14:40:12
I can't find any information about the differences between: android:textColor="?attr/colorPrimary" vs android:textColor="?colorPrimary" I have read that "?attr" means attribute value specified in the current theme, but without "attr" it gives the same result (=color defined in my theme). It behaves similar with other attributes? For example: Does android:background="?attr/selectableItemBackground" equals android:background="?selectableItemBackground" ? Here it's told that it differs. Thanks very much. Ok, I have finally found in the docs: Because the system resource tool knows that an

Custom attribute not resolved inside styles and theme

孤人 提交于 2019-12-04 03:19:09
问题 I have android application with custom themes which was developed 2-3 year ago. I had this stylable in my attr.xml resouce file: <declare-styleable name="EVETextViewPlus"> <attr name="customFont" format="string" /> <attr name="pageStripFont" format="string" /> </declare-styleable> And I've used this inside my style_warm.xml resource file: <?xml version="1.0" encoding="utf-8"?> <resources xmlns:android="http://schemas.android.com/apk/res/android" <style name="style_display_page_title_warm">

How to reference style attributes from a drawable?

随声附和 提交于 2019-11-26 11:07:32
I want to have 2 selectable themes for my application. In order to do that, I defined some attributes, like this: <attr format="color" name="item_background" /> Then, I created both themes, like this: <style name="ThemeA"> <item name="item_background">#123456</item> </style> <style name="ThemeB"> <item name="item_background">#ABCDEF</item> </style> This method works great, allowing me to create and modify several themes easily. The problem is that it seems that it can be used only in Views, and not in Drawables . For example, referencing a value from a View inside a layout works: <TextView