Tag: layout

Performance: How to prevent requestLayout() from laying out entire hierarchy

I have a pretty complex android-application. Already flattened view-hierarchies as far as possible, but I still have lags in the application. For example there is a menu with entries that collapse/expand by having their height set by a ValueAnimator. Typically the animation runs with a bit of a lag the first time, and smooth after […]

What is the difference between android:layout_width and android:width

I do not know the difference between these two attributes and for the height also. Take a TextView for example, what would happen if I set its layout_width to wrap_content and set its width to 50 dip?

How to change layout (without coding) in Android Studio

How do I change the layout in android studio without coding? I know that in eclipse ADT I just had to right click on the layout I wanted to change in the Outline and choose the option “change layout”. How do I do this in Android Studio. I can not find the answer anywhere.

ViewPager using xml files for the views

I want to use three previously created Activities in a ViewPager (with PagerAdapter) so the user can scroll smoothly horizontally through them. I followed a tutorial which worked great. The problem is in the tutorial they use TextViews to demonstrate. I already have finished Activities (of which the layouts are in XML files). I want […]

Android square imageview

im trying to make a table with square imageviews (and all with the same size). The problem is that the images have different height and width. The table is 3×3 and i’d like to: each cell have a with = 1/3 of the screen width (maybe with the layout weight?) and height =width Much better […]

Resizing layouts programatically (as animation) up to “wrap_content”

I’m facing very similar issue as here: Resizing layouts programmatically (as animation) and the solution there is great but I need one more feature. I’d like to animate the resizing from height = 0 to height = WRAP_CONTEN. But have no idea how to measure the wrap content size. So I need somehow detect that […]

Use single xml layout for multiple activities with different datas

I know this is a very basic question, however as a newbie i cant get to work around it. So, I want to have multiple activities to use same the xml layout(consist for example of 1 imagebutton, and multiple textviews with different IDs). Now, for every activity, I want them to view the same layout […]

Error inflating layout of FloatingActionButton : NoSuchMethodException

So I’m getting an error inflating the layout, something about NoSuchMethodException. I’ve looked at other solutions to this and I’ve made sure that I’ve done the following, which I have, and I’m still getting the exception. Does anyone know what could be causing this??! I am completely lost, everything was working fine and then I […]

Android: Set alpha on button on click. Preferably xml only

I want to introduce a ‘down’ style on some buttons. I’ve created a style, and a state list. <selector xmlns:android=”http://schemas.android.com/apk/res/android”> <item android:drawable=”@drawable/inactive_button_background” android:state_enabled=”false”/> <item android:drawable=”@drawable/active_button_background” android:state_enabled=”true”/> <item android:drawable=”@drawable/pressed_button_background” android:state_pressed=”true”></item> </selector> The problem is that I want to be able to change just the alpha of the background when the button gets clicked (I will have […]

android ImageButton scale and maintain aspect ratio

I have a screen that I’m trying to layout… Basically, I’m trying to evenly distribute 4 ImageButton objects vertically on a screen… I used this here to evenly distribute the items, but now am having a terrible time getting the images to scale but maintain aspect ratio… if I use scaleType=”centerInside” they don’t scale, if […]

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