Category "android-layout"

How to achieve click effect on ShapeableImageView, min api 21 without nesting view

Is there a better way to achieve click effect on ShapeableImageView with recent release of Material components v1.2.0 I do not want to use foreground property a

Material Date Picker title is out of place

I'm having this weird issue when using MaterialDatePicker. While it works, the title and current date are not displaying as they should. Any ideas on what is ha

ScrollView does not show content when its constrained by "Match-constrains" inside a layout

I have a ScrollView inside my Constrained layout which contains another constrained layout, the view does not show its content if I set its height to "Match-Con

Android: set just one padding of textview programmatically

I want to set the top padding of a textview programmatically. I know you can do this with the method setPadding(). But the problem is that this method requires

Set View Width Programmatically

I am trying to set the width and height of a view in code to show an ad for a free app I am working on. All of the UI is done in XML with the exception of this

Unnecessary padding in CardView?

I have implemented CardView in my app and everything works fine except there is a little padding around the image if I put radius to the card. It appears like

TabLayout gravity center is not working

I have a TabLayout, where I want the tabs to be displayed in the center of the screen. Below is the XML for my TabLayout. <android.support.design.widget.Tab

Get specific drawable from state list drawable

I have a state list drawable, and i want to get a specific drawable from the state list drawable: <?xml version="1.0" encoding="utf-8"?> <selector xml

Add padding on view programmatically

I am developing Android v2.2 app. I have a Fragment. In the onCreateView(...) callback of my fragment class, I inflate an layout to the fragment like below: @Ov

Android layouts - Most efficent way to achieve what i'm after

I've been doing a bit of searching around for ways to achieve what i'm after but haven't been able to find much. Basically i'm going to use this as a "home" sc

centrally align icons in gridview

I want the icons to be centrally placed on the screen with proper alignment. What are the parameters I need to set? I have tried android:gravity and android:lay

RelativeLayout is taking fullscreen for wrap_content

Why does FOOBARZ get layed out all the way at the bottom when no elements are layout_height="fill_parent" in other words, all elements are wrap_content for heig

Android image scale type to fit width and scaleY = scaleX

I have a layout with a background image. The image width should be the same as the screen width (match_parent). But it's ugly, the OS don't stretch the picture

what is ems and why the editfield size is same (width)?

I just started android development, so I have two question in my mind First, why the size of edit field does not change its width. Secondly, what is the meani

Set android shape color programmatically

I am editing to make the question simpler, hoping that helps towards an accurate answer. Say I have the following oval shape: <?xml version="1.0" encoding=

How to customize a Spinner in Android

I want to add a custom height to the dropdown of a Spinner, say 30dp, and I want to hide the dividers of the dropdown list of Spinner. So far I tried to implem