Tag: layout

GridView and excess space padding

I have a problem with grid view layout on Android. I can’t find solution to eliminate extra space in grid view. I tried a lot of things (numColumns, columnWidth, stretchMode, gravity) and advices (from StackOverflow), but nothing works correctly. I spent almost 8 hours with this problem. Here is a code of grid view: <GridView […]

How to vertically align text in a TextView with Compound Drawable

This question is in a way a continuation of my last question. My problem now is pretty much the same, except that instead of separating the image and text in differend views (namely ImageView and TextView) I learned I can use the attribute android:drawableLeft to set an image “for” my text (the suggestion was pointed […]

How to get an Android widget's size after layout is calculated?

I have a layout which specifies sizes of widgets in relative dimension, for example: <LinearLayout … layout_height=”fill_parent”> <ImageView … layout_height=”wrap_content” /> <TextView … layout_height=”120dp” /> </LinearLayout> Immediately after onCreate, I want to know how much is the height of the ImageView. How to do that? Note: If I call getHeight() in onCreate, I get 0. […]

Move snackbar above the bottom bar

i am facing some problems with new bottom bar. I can’t force to move the snackbar above the bottom bar (this is how design guideline told me should be https://www.google.com/design/spec/components/bottom-navigation.html#bottom-navigation-specs). This is my activity_main.xml <?xml version=”1.0″ encoding=”utf-8″?> <android.support.v4.widget.DrawerLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” xmlns:tools=”http://schemas.android.com/tools” android:id=”@+id/drawer_layout” android:layout_width=”match_parent” android:layout_height=”match_parent” android:fitsSystemWindows=”true” tools:openDrawer=”start”> <include layout=”@layout/app_bar_main_activity” android:layout_width=”match_parent” android:layout_height=”match_parent” /> <android.support.design.widget.NavigationView android:id=”@+id/nav_view” android:layout_width=”wrap_content” android:layout_height=”match_parent” […]

Which is the best layout in android we can use to design the UI?

I am using Absolute layout for my UI design in android. My doubt is which layout is best for UI design in android and Is it the design is change in any other device. That means i am using HTC Desire to test my application if i installed my app in any other app means […]

What is setContentView(R.layout.main)?

I understand that it has to do with the App layout, but when do I have to use it? I tried to look for a link that explained this method, but I couldn’t find it. Thank you in advance!

Example of custom setDropDownViewResource spinner item

I would like to display two values in an drop down view of my spinner. Currently, it only has a city name, but I would also like to add a small distance field to it. MyCity<MyCityDistance> dataAdapter; dataAdapter = new MyCity(this, R.layout.mycityrow, list); dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); I have all the code for custom data adapter, exapanding my […]

Evenly spaced button in Layout

I’m trying to make 4 buttons, evenly spaced in a portrait view on Android. The space should scale up and down depending on the screen size, with an even amount of space between each button and the borders. I tried using linear layout, weight and layout gravity but it seems that I cannot center the […]

ImageButton does not display a particular drawable

This is rather a funny problem I have ever come across, I have a table layout with 9 image buttons, 3 per row. Every ImageButton has a different image associated with it. I have set the background of the image button to transparent (#00000000). Now here is where the funny stuff happens, One of the […]

Get position of imageview on layout android

Please help me i want to get position of imageview on a layout.

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