android-xml

How to add a horizontal 1px line above image view in a relative layout?

喜夏-厌秋 提交于 2019-11-27 13:41:23
问题 How do I add a horizontal 1px white line above image view in a relative layout? <RelativeLayout android:id="@+id/widget38" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_x="108px" android:layout_y="87px" > <ImageView android:id="@+id/widget39" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_alignParentRight="true" > </ImageView> </RelativeLayout> 回答1: Just add the following

Android getMeasuredHeight returns wrong values !

筅森魡賤 提交于 2019-11-27 12:19:43
I'm trying to determine the real dimension in pixels of some UI elements ! Those elements are inflated from a .xml file and are initialized with dip width and height so that the GUI will eventually support multiple screen size and dpi ( as recommended by android specs ). <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="150dip" android:orientation="vertical"> <ImageView android:id="@+id/TlFrame" android:layout_width="110dip" android:layout_height="90dip" android:src="@drawable/timeline_nodrawing" android:layout

error: Error parsing XML: not well-formed (invalid token) …?

回眸只為那壹抹淺笑 提交于 2019-11-27 11:54:54
I am working on an application, with following XML. but whenI try to clean/build my project the following error occurs: "error: Error parsing XML: not well-formed (invalid token)" <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello"; /> </LinearLayout> What does it possibly mean? It means there is a compilation error in your

How to get accent color programmatically?

拈花ヽ惹草 提交于 2019-11-27 11:50:20
问题 How would one fetch the accent color set in styles, like below, programmatically? <item name="android:colorAccent">@color/material_green_500</item> 回答1: You can fetch it from the current theme in this way: private int fetchAccentColor() { TypedValue typedValue = new TypedValue(); TypedArray a = mContext.obtainStyledAttributes(typedValue.data, new int[] { R.attr.colorAccent }); int color = a.getColor(0, 0); a.recycle(); return color; } 回答2: This worked for me as well: public static int

How can I draw circle through XML Drawable - Android? [duplicate]

你说的曾经没有我的故事 提交于 2019-11-27 11:02:42
问题 This question already has an answer here: How to get round shape in Android [duplicate] 1 answer I'm trying to draw circle with the help of XML file in android, but circle is not displaying properly. Below code is showing Oval. How can I create circle in XML file. <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> <gradient android:startColor="#FFFF0000" android:endColor="#80FF00FF" android:angle="45"/> <padding android:left="2dp" android:top="2dp" android

How can you get the Manifest Version number from the App's (Layout) XML variables?

做~自己de王妃 提交于 2019-11-27 10:09:51
I would like to have a way to reference the project's manifest version number in the main part of the code. What I have been doing up until now is to link the version number in a String XML file to the manifest (@string/Version). What I would like to do is to do it the other way around, link a string XML variable to the version in the manifest. The reason? I'd like to only have to change the version number in one location, the manifest file. Is there any way to do this? Thanks! Konstantin Burov I believe that was already answered here . String versionName = getPackageManager().getPackageInfo

No shadow/elevation underneath second card if there are two card in the layout. Why?

旧时模样 提交于 2019-11-27 09:52:47
I have 2 cards in a single RelativeLayout . The problem is that there is no elevation or shadow underneath the second card. See the screenshot here: screenshot Here's what I have done in the xml file: <?xml version="1.0" encoding="utf-8"?> <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:background="@color/colorPrimary" xmlns:app="http://schemas.android.com/apk/res-auto" android:paddingBottom="@dimen/activity_vertical_margin" android

format statement in a string resource file

谁说我不能喝 提交于 2019-11-27 06:10:55
I have strings defined in the usual strings.xml Resource file like this: <string name="hello_world"> HELLO</string> Is it possible to define format strings such as the one below result_str = String.format("Amount: %.2f for %d days ", var1, var2); in the strings.xml resource file? I tried escaping the special characters but its not working. LocalPCGuy You do not need to use formatted="false" in your XML. You just need to use fully qualified string format markers - %[POSITION]$[TYPE] (where [POSITION] is the attribute position and [TYPE] is the variable type), rather than the short versions, for

Unknown attribute android:layout_width, layout_height, id, gravity, layout_gravity, padding

廉价感情. 提交于 2019-11-27 05:30:36
问题 Getting Unknown attribute error on all android tag. In layout XML, Auto suggestion is not showing all attributes (like layout_width, layout_height, orientation, orientation & all others android attributes.) Here is a Snap shot Things i have done to resolve this issue. Clean Build & Rebuild Deleted .idea file Invalidated Caches/ Restart.. option Turn On Power Save Mode. SDk is up to date. In App Level Gridle apply plugin: 'com.android.application' android { compileSdkVersion 23

i want to make my application only in landscape in android

感情迁移 提交于 2019-11-27 05:24:05
问题 I want to make my app work only in landscape mode but can't make it work. I have given screenOrientation = "landscape" even though the first page will be in landscape mode and other activity will be in portrait. XML FILE <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".Main" android:label="@string/app_name" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"> <intent-filter> <action android:name=