Tag: xml

Android: Specify two different images for togglebutton using XML

I’m attempting to override the default ToggleButton appearance. Here’s the XML that defines the ToggleButton: <ToggleButton android:id=”@+id/FollowAndCenterButton” android:layout_width=”30px” android:layout_height=”30px” android:textOn=”” android:textOff=”” android:layout_alignParentLeft=”true” android:layout_marginLeft=”5px” android:layout_marginTop=”5px” android:background=”@drawable/locate_me”/> Now, we have two 30 x 30 icons we want to use for the clicked/non-clicked states. Right now we have code that programmatically changes the background icon depending on the […]

Android: Add a textview to linear layout programmatically

I am trying to add TextViews to my xml-defined layout in code. I have a xml-sheet, where a lot of Views are defined. But I have to add some views in code, so a create a LinearLayout in the xml-sheet: <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”wrap_content” android:id=”@+id/info” android:layout_height=”wrap_content” android:orientation=”vertical”> </LinearLayout> And in this layout, I like to add […]

Favourite content is not shown correctly on webview

I’m developing a language dictionary app. I save the favourite word into Preference. The Favourite content in the XML file looks like the following: <?xml version=’1.0′ encoding=’utf-8′ standalone=’yes’ ?> <map> <string name=”history”> dict_name::160170::hi,dict_name::157140::he-man,dict_name::184774::jet,dict_name::34527::black </string> <string name=”waitingTime”> 0 </string> <boolean name=”saveFavourite” value=”true” /> <string name=”defaultDictionary”> dict_name </string> <string name=”favourite”> dict_name::149271::go,dict_name::25481::back,dict_name::184774::jet </string> <boolean name=”saveHistory” value=”true” /> </map> […]

android.content.res.Resources$NotFoundException: String resource ID #0x0

I’m developing an Android app which reads data from MySQL database and I faced this error. I have this XML layout: <?xml version=”1.0″ encoding=”utf-8″?> <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”match_parent” android:layout_height=”match_parent” android:orientation=”vertical” > <TextView android:id=”@+id/wardNumber” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_marginLeft=”3dp” android:text=”Ward Number” android:textSize=”22dp”/> <TextView android:id=”@+id/dateTime” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_below=”@id/wardNumber” android:layout_alignParentRight=”true” android:layout_marginRight=”3dp” android:text=”Date-Time” /> <TextView android:id=”@+id/name” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_alignBaseline=”@+id/dateTime” android:layout_alignBottom=”@+id/dateTime” android:layout_alignLeft=”@+id/wardNumber” android:layout_marginLeft=”3dp” […]

Moving and vanishing lines of code; trouble with Eclipse's XML Editor

Sometimes my code moves on its own or just disappears in the Eclipse XML editor. When I highlight the affected code, the highlighted lines try to correct themselves. But when I scroll or drag the mouse in the opposite direction the code shifts again. In essence I will have repeating, missing, and broken lines of […]

Making a triangle shape using xml definitions?

Is there a way that I can specify a triangle shape in an xml file? <shape xmlns:android=”http://schemas.android.com/apk/res/android” android:shape=”triangle”> <stroke android:width=”1dip” android:color=”#FFF” /> <solid android:color=”#FFF” /> </shape> can we do this with a path shape or something? I just need an equilateral triangle. Thanks

XML Rendering errors Android preview N

I have updated android SDK to android preview N after updating, I am getting this xml rendering error. After clicking on details it is showing following stack trace How to avoid this org.jetbrains.android.uipreview.RenderingException: Failed to load the LayoutLib: com/android/layoutlib/bridge/Bridge : Unsupported major.minor version 52.0 at org.jetbrains.android.uipreview.LayoutLibraryLoader.load(LayoutLibraryLoader.java:90) at org.jetbrains.android.sdk.AndroidTargetData.getLayoutLibrary(AndroidTargetData.java:180) at com.android.tools.idea.rendering.RenderService.createTask(RenderService.java:166) at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:649) at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1700(AndroidLayoutPreviewToolWindowManager.java:80) at […]

android.view.InflateException: Binary XML file line #12: Error inflating class <unknown>

I am receiving many errors of kind displayed in the subj. These errors seems to be occasional and I cannot reproduce them. From stack I can learn that such error may occurs for my different layout resources. The line of XML is also varying. Can anybody explain why this error occurs? And what I can […]

XML Android Permissions List Full

I wish I could find this list before I made it. If for some strange reason you also need this, it is here for you. Only because I care. Now, like never before, give your apps full power. <uses-permission android:name=”android.permission.ACCESS_CHECKIN_PROPERTIES” /> <uses-permission android:name=”android.permission.ACCESS_COARSE_LOCATION” /> <uses-permission android:name=”android.permission.ACCESS_FINE_LOCATION” /> <uses-permission android:name=”android.permission.ACCESS_LOCATION_EXTRA_COMMANDS” /> <uses-permission android:name=”android.permission.ACCESS_MOCK_LOCATION” /> <uses-permission android:name=”android.permission.ACCESS_NETWORK_STATE” […]

CollapsingToolbarLayout doesn't recognize scroll fling

I have created a simple CollapsingToolbarLayout and it works like a charm. My problem is, that if I try to use a fling scroll on the nestedscrollview, it just stops when I release my finger. Normal scrolling works like it should. My activities code is unchanged => auto generated empty activity. (I just clicked on […]

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.