Tag: layout

How to set integer tag to a widget in xml layout file?

I have simple layout, but I can only set string tag. How to set integer tag? <ImageView android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:tag=”1″ android:src=”@drawable/image” /> UPDATE I found out how to set Integer tags in xml layout. We need to specify an integer variable in any xml resource file. That should look like that: res/values/value.xml: <?xml version=”1.0″ encoding=”UTF-8″?> […]

Difference between setContentView and LayoutInflater

I am creating a tabs list with several fragments. I have noticed that, in the main activity, I used setContentView to get the layout xml and use findViewById to get the corresponding UI element config. setContentView(R.layout.fragment_tabs); mTabHost = (TabHost)findViewById(android.R.id.tabhost); mTabHost.setup(); mTabManager = new TabManager(this, mTabHost, android.R.id.tabcontent); However, in the different fragment class, I have to […]

Unexplained gap/padding to the left, between Toolbar, and LinearLayout

I have the following structure in the layout file of my Android studio project, and I see unexplained left padding between the parent element (Toolbar) and it’s immediate child element (LinearLayout). Layout Text <Toolbar android:layout_width=”fill_parent” android:layout_height=”600dp” android:id=”@+id/toolbar” android:background=”#313B45″ android:weightSum=”1″> <LinearLayout android:layout_width=”match_parent” android:layout_height=”match_parent” android:orientation=”vertical”> <ImageView android:id=”@+id/headerimage” android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:scaleType=”fitXY” android:layout_gravity=”left|top” android:layout_weight=”1″/> <TextView android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:text=”New Text” […]

Android Studio: Error parsing XML & URI is not registered

After adding a new Activity to my project I get following error while compiling the layout Gradle: Error parsing XML: not well-formed (invalid token) <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:orientation=”vertical” > <TextView android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:id=”@+id/tv_password” android:text=”<password>”/> </LinearLayout> “http://schemas.android.com/apk/res/android” is marked red and hovering pops following message up URI is not registered ( Setting | Project Settings […]

Android: How to fill RelativeLayout to full width of screen?

I am creating an Android app which has a main RelativeLayout and some LinearLayout within it. Now i have this problem. When dragging items to the editor, e.g. a LinearLayout, it doesn’t fit to the full width of the screen. How can I make this possible? This is my XML: <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:tools=”http://schemas.android.com/tools” android:layout_width=”fill_parent” android:layout_height=”fill_parent” […]

What happens if I leave all of my images in the drawable-hdpi folder?

I have all of my images in the drawable-hdpi folder. And I finished all of my layouts for all screen sizes. But i forgot to put the images in the drawable-mdpi folder and drawable-ldpi folder. If a phone with an mdpi screen density were to download my application would it just use the images in […]

java android.support.v4.widget.DrawerLayout not being found

android.support.v4.widget.DrawerLayout; is not being found on my phone when I test the app. why is this happening and how do I fix it? I don’t know yet but I think I may be having the same problem with android.support.v4.view.GravityCompat; and android.support.v4.app.ActionBarDrawerToggle; if they do cause any problems. I have never had any problems with android.support.v4.*; […]

How to make the linearlayout in scrollview to fill the whole area

<RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”match_parent” android:layout_height=”match_parent” android:orientation=”vertical” > <ScrollView android:id=”@+id/scrollView1″ android:background=”#000000″ android:layout_width=”match_parent” android:layout_height=”match_parent” > <LinearLayout android:id=”@+id/linear1″ android:background=”#FF0000″ android:orientation=”vertical” android:layout_width=”match_parent” android:layout_height=”match_parent” > <LinearLayout android:background=”#00FF00″ android:id=”@+id/linear2″ android:layout_width=”match_parent” android:layout_height=”200dip” android:orientation=”vertical” > </LinearLayout> <LinearLayout android:background=”#0000FF” android:id=”@+id/linear3″ android:layout_width=”match_parent” android:layout_height=”100dip” android:orientation=”vertical” > </LinearLayout> </LinearLayout> </ScrollView> </RelativeLayout> This is my layout and I expected to see a red background (because linear1 have background red […]

GridLayoutManager – how to auto fit columns?

I have a RecyclerView with a GridLayoutManager that displays Card Views. I want the cards to rearrange according to the screen size (the Google Play app does this kind of thing with its app cards). Here is an example: Here is how my app looks at the moment: As you can see the cards just […]

Layout on Samsung Galaxy Note

I have a weird issue that only occurs on the Samsung Galaxy Note. I have landscape and portrait layouts , in normal and large , as per : http://developer.android.com/guide/practices/screens_support.html On all phone so far it uses the normal and the tablets 7inch and 10 inch use the large layout (which was designed for tablets) and […]

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