Questions tagged [android-layout]

A layout defines the visual structure for a user interface, such as the UI for an activity, fragment or app widget.

An Android layout defines everything the user can see and touch. A layout is made up of View (like buttons and text) and ViewGroup (like lists, tables, or more Views) objects, all combined to make a View Hierarchy:
View Hierarchy
(from Android's UI Overview)

Designing a Layout:

You can create your layout in any combination of these two ways:

  1. Declare UI elements in XML.
    Android provides a straightforward XML vocabulary that corresponds to the View classes and subclasses, such as those for widgets and layouts.

  2. Instantiate layout elements at runtime.
    Your application can create View and ViewGroup objects (and manipulate their properties) programmatically.

Common Layouts:

Each subclass of the ViewGroup class provides a unique way to display the views you nest within it. Below are some of the more common layout types that are built into the Android platform.

  1. Linear Layout: A layout that organizes its children into a single horizontal or vertical row. It creates a scrollbar if the length of the window exceeds the length of the screen.
  2. Relative Layout: Enables you to specify the location of child objects relative to each other (child A to the left of child B) or to the parent (aligned to the top of the parent).
  3. Constraint Layout: Allows positioning children relative to each other and the parent. But also offers other powerful positioning and sizing strategies, including horizontal/vertical child "chains" with custom spacing/weighting, arbitrary horizontal/vertical "guidelines," and custom child size aspect ratios.
  4. Web View: Displays web pages.
  5. Frame layout: FrameLayout is designed to block out an area on the screen to display a single item.
  6. Grid View: GridView is a ViewGroup that displays items in a two-dimensional, scrollable grid.

Useful Links:

57356 questions
15
votes
3 answers

Bottomsheet with moving Floating action buttons

I want to use Bottom-sheet from support library and two floating action buttons (FABS) as shows the pictures. The point is that I also want both FABS moving together with the bottom-sheet like the picture 1 and 2. What is the basic layout that I…
15
votes
6 answers

Android : Cardview Background is turning to black on 4.1.2

I am using google cardView support library for my card functionality. It works well for kitkat and version up but however the background of card is set to black and padding/margins are not applied on device…
Sutirth
  • 867
  • 3
  • 11
  • 24
15
votes
3 answers

Multiline Text view in CollapsingToolbarLayout instead of Title

I want to display some text in Collapsing toolbar instead of title. Problem is that text may contain more than 1 line. So I need to use custom view, but can't understand how to implement it in proper way. Also, how to set minimal CollapsingToolbar…
15
votes
1 answer

Soft keyboard's POPUP layout

I'm developing a soft keyboard and doing well, but I don't know how to customize the popup layout for a long keypress. My KeyboardView:
15
votes
2 answers

Android - edittext - no textselection handles are shown and no sharing option

On an App screen I have a number of EditText views. My app is built using the Material Design (AppCompactActivity, etc). While showing an EditText field, with a long press I try to select a number of words in the text. This allows me to copy or…
tm1701
  • 5,984
  • 6
  • 53
  • 117
15
votes
4 answers

How to use layout_aspectRatio in the PercentRelativeLayout?

I try to achieve a 16:9 aspect ratio on a view with the PercentRelativeLayout. So I have put this line in my build.gradle file: compile 'com.android.support:design:23.0.1' I use this layout:
15
votes
1 answer

Unable to make two way view with 2 rows

I am using LucasR TwoWayView. I want the View to have 2 rows and multiple columns. Like the 4th Image in this picture except with 2 rows instead of 3. I tried many things but no use. Here is my Layout:
Akshat
  • 1,837
  • 5
  • 31
  • 70
15
votes
3 answers

ViewPager in CoordinatorLayout shrinks unexpectedly

In my Android app running on Android 5.1.1 I have a layout using a Toolbar with a TabLayout, and underneath is a ViewPager. All of these are put together in a CoordinatorLayout. In the first page of the ViewPager is a RecyclerView serving CardView…
15
votes
4 answers

Borderless Button on Pre-Lollipop with Support Library

I am making borderless flat button using support library (23.0.1). It works normal on Lollipop. However on pre-Lollipop when I press button Its color changes to colorButtonNormal color like it's a normal button. I don't think so it's a normal…
15
votes
3 answers

Android Floating Action Button options Menu

There are lots of custom libraries for achieving the FAB menu thing. But I want it to be done without using any custom libraries. I want to achieve this FAB Menu natively. Please don't suggest me any custom library
asad.qazi
  • 2,310
  • 3
  • 21
  • 33
15
votes
4 answers

How to add Three Level ListView in ExpandableListView in android

I want to add one more level of in ExpandableListView.In current ExpandableListView is two level how can i add one more level. I am new in android developing please help me. Thanks in advance! My MainActivity.java:- private Toolbar…
Anand Jain
  • 2,227
  • 6
  • 33
  • 64
15
votes
6 answers

collapsing toolbar layout like google play store

i want to make a collapsing toolbar layout like google play store. like this: https://sendvid.com/ugjspx8r and here is my layout: http://sendvid.com/s4mx3xem how can i do that with new android support library? here is my layout xml…
15
votes
4 answers

Why does my layout get messed up after clearing FLAG_TRANSLUCENT_STATUS flag?

I have a single Activity application. It displays a LoginFragment which makes Status and Navigation bars translucent so that it can display a background image behind it. However, after login this fragment is replaced by another fragment which needs…
AppleGrew
  • 8,547
  • 22
  • 70
  • 117
15
votes
2 answers

How can I programmatically decompile dex files within Android?

I know how to extract apk files to classes using a windows based system as below: Step 1:Renaming .apk file Rename the .apk file with the extension .zip (for example let the file be "demofile.apk" then after renaming it becomes…
user4920338
1 2 3
99
100