android-resources

How to get a value of color attribute programmatically

馋奶兔 提交于 2020-03-18 05:21:06
问题 When I use resolveAttribute() to find out a color value of ?attr/colorControlNormal , I got 236 : TypedValue typedValue = new TypedValue(); getTheme().resolveAttribute(R.attr.colorControlNormal, typedValue, true); int color = typedValue.data; // 236 But when I use an XML layout with the following TextView element: <TextView android:id="@+id/textView" style="?android:attr/textAppearance" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="?attr

How to get a value of color attribute programmatically

痞子三分冷 提交于 2020-03-18 05:20:29
问题 When I use resolveAttribute() to find out a color value of ?attr/colorControlNormal , I got 236 : TypedValue typedValue = new TypedValue(); getTheme().resolveAttribute(R.attr.colorControlNormal, typedValue, true); int color = typedValue.data; // 236 But when I use an XML layout with the following TextView element: <TextView android:id="@+id/textView" style="?android:attr/textAppearance" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="?attr

How to get a value of color attribute programmatically

爱⌒轻易说出口 提交于 2020-03-18 05:20:03
问题 When I use resolveAttribute() to find out a color value of ?attr/colorControlNormal , I got 236 : TypedValue typedValue = new TypedValue(); getTheme().resolveAttribute(R.attr.colorControlNormal, typedValue, true); int color = typedValue.data; // 236 But when I use an XML layout with the following TextView element: <TextView android:id="@+id/textView" style="?android:attr/textAppearance" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="?attr

how to know which phone support which layout(hdpi , mdpi and xhpi)?

假如想象 提交于 2020-03-11 02:42:06
问题 I'm a little confused about how to determine which phones support what layout types. I've done some research but haven't found a satisfying answer. For example, I've found the below guide: xlarge screens are at least 960dp x 720dp large screens are at least 640dp x 480dp normal screens are at least 470dp x 320dp small screens are at least 426dp x 320dp However, I still have some concerns: Samsung grand (480*800) and HTC wild fire S (320*480) both support MDPI. These screens have very

Resource is not a Drawable Resources$NotFoundException

安稳与你 提交于 2020-02-03 23:42:48
问题 Getting this error since I started changing device for testing. Did some searching and none of it help because they are outdated. Any help is appreciated! xml file <ImageView android:id="@+id/loginpanel" android:layout_width="491px" android:layout_height="210dp" android:layout_marginStart="41dp" android:layout_marginTop="146dp" android:layout_weight="1" android:background="@drawable/loginpanel" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" />

Resource is not a Drawable Resources$NotFoundException

爷,独闯天下 提交于 2020-02-03 23:42:33
问题 Getting this error since I started changing device for testing. Did some searching and none of it help because they are outdated. Any help is appreciated! xml file <ImageView android:id="@+id/loginpanel" android:layout_width="491px" android:layout_height="210dp" android:layout_marginStart="41dp" android:layout_marginTop="146dp" android:layout_weight="1" android:background="@drawable/loginpanel" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" />

Difference between R.string.xxx and getString(R.string.xxx)?

半腔热情 提交于 2020-01-30 12:03:29
问题 What is the difference between two ways to obtain a string from resources: setPositiveButton(R.string.some_string); OR setPositiveButton((getString(R.string.some_string)); ? In both cases I get the same result. 回答1: R.string.some_string is a public final static int that is a fixed ID to a specific String in your R.java file. This is generated automatically. getString(R.string.some_string) returns the String referenced by the above by reading the R.java file. It depends on the implementation

Better to load resources on the run or to pre load them on memory?

狂风中的少年 提交于 2020-01-25 18:55:08
问题 I'm developing an app that spans across several classes, and as such, I've had to pass on the app's Context to all of the classes that use global strings or integers so as to extract them from the strings.xml or dimens.xml files instead of hard coding them. Up until now I've been loading the resources once needed but I was wondering if it would be more efficient to load all the resources I would need on a class in the Constructor, keep in mind that they're only strings and integer values. 回答1

Does android reuse images loaded from resource?

空扰寡人 提交于 2020-01-24 04:09:47
问题 So I have several ImageViews in a single Activity and all of them use the same image bitmap from a resource. ImageViewOne.setImageResource(R.drawable.frequently_used_image); ImageViewTwo.setImageResource(R.drawable.frequently_used_image); ImageViewThree.setImageResource(R.drawable.frequently_used_image); Does android allocate memory to load the bitmap once and reuse it for all other ImageViews using the same resource? Or does it load the bitmap each time it is set to an ImageView? Thanks! 回答1

Could android store drawable ids like an integer-array?

不想你离开。 提交于 2020-01-23 01:54:09
问题 I want a drawable id array of integer values which I can store like an integer-array in res/values/XXX.xml by using integer-array tag. Below is integer-array declared in strings.xml <integer-array name="icons"> <item>1</item> <item>2</item> <item>3</item> <item>4</item> </integer-array> But I want to store drawable image ids like @drawable/someImage as an integer array in xml. OR Is there any alternatives to store drawable integer ids as an integer array in xml. 回答1: I think TypedArray is