Questions tagged [android-layout]

13595 questions
-2

votes
0

answer
9

Views

SQLiteException: no such column: firstname (code 1):

I'm working with databases and I have the following DbHelper class. and I am the beginner in SQLite database public class DbHelper extends SQLiteOpenHelper { private static final int DATABASE_VERSION = 1; private static final String CREATE_TABLE = "CREATE TABLE "+DbContract.TABLE_NAME +"("+DbContrac...
rahul
1

votes
4

answer
1.3k

Views

Why is my DialogFragment not showing the custom layout?

I want to show a DialogFragment with no title, buttons, etc.(i.e, none of what is included in a typical Dialog) but just a ProgressBar spinner on a plain background. For a rough idea, the background's width matches that of the parent and spinner lies at the center of it. For this, I have a custom la...
pulp_fiction
4

votes
4

answer
126

Views

Unable to edit ActionBar title from Fragment in ViewPager

I have a single Activity which hosts multiple fragments through a ViewPager. In the Activity's onCreate method I'm using the following code to change the ActionBar title: Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); if(getSupportActionBar() != null) { getSupportActionB...
LS_
0

votes
0

answer
3

Views

Android custom view - disable layout_height/width in XML and set default value for them in java class

I'm working on a custom button component and is there any way to disable the layout_height and layout_width in XML only for this button? I have set up the default height and width in Java class, but I was still asked for the layout_height and layout_width in XML (which will override my default value...
Karass
1

votes
1

answer
27

Views

Is it good practice to only use LinearLayout for a Layout that only plans on using one screen?

I have a screen in my Android Application that only takes up one screen. Because of this, I thought it would be really quick and easy to just use LinearLayout as my base layout: I thought this would be good. However, I am thinking, what if someone uses a 2.7 inch screen on their smartphone? Or they...
Slaknation
0

votes
0

answer
6

Views

How to set 2 tab takes equal width in tablayout

I am adding 2 tab in tablayout, and following is my code. I am getting following output. But i want tabs to take full width of screen, like following. Following is my AppTabLayout style defined in styles.xml file. @null 1dp 16dp 16dp @color/white
Kirmani88
0

votes
0

answer
11

Views

Visual Studio 2017 Xamarin align editviews on their left edge

I'm trying to align all the editview's in the layout below on their left edge. The top one and the bottom one align fine because they're basically the same. The middle one (middle initial) aligns on the right edge with the other editviews. How can I align them on their left edge? /> />
Prescott Chartier
1

votes
2

answer
1.4k

Views

Setting view height dependent on its width in android in layout xml

Is it possible that a view should make it height same as it's width? or any other layout for this purpose, because for vector image it's compulsory to provide width and height.
Vivek Kumar
7

votes
2

answer
186

Views

Rejecting peripheral touch inputs

Given a nested view structure such as: How do I disable input on the grey periphery, such that even as the user holds a finger on it, but touches the yellow view, the touch event would register in dispatchTouchEvent() for that view unhindered? EDIT: To explain a bit further, I need some kind of palm...
Gleno
1

votes
1

answer
875

Views
1

votes
1

answer
188

Views

Sync scroll of horizontal recylerview with viewpager scroll

i have a view pager with some values, same count for the recycler view abovethe recylerview(Act like a tablayout) i have achieved the function with snap helper and all working fine only thing i want is i want to sync the scroll of the recyclerview with viewpager scroll, which i cant able to achive....
1

votes
1

answer
799

Views

Last Item in recyclerview is cut off

I am using recyclerview to display a list of items and constraint layout is the parent view. The layout is displayed below: The adapter layout for each row is presented below: After running my application the layouts are presented in the image below: I tried adding a bottom margin to the recycle v...
George Mujuru
1

votes
1

answer
1.5k

Views

What should I use for margins, sp or dp?

I have seen some people using sp for margins like: android:layout_marginLeft="40sp" While many have been using dp, like: android:layout_marginLeft="40dp" Could anyone please confirm which is better between these two and which should be used when? Any help would be highly appreciated.
user1903022
0

votes
0

answer
6

Views

how to support all screen sizes when using more than one spinner?

I am making a new app and I am a beginner so kindly help me with this, my layout is working great if I run without any java code for layout but when I use Java code, my layout is going beyond the screen I have tried to make different layout folders such as layout-sw320dp.... public class Main2Activi...
ashim
1

votes
2

answer
346

Views

Detect when the application is completely drawn and visible

In short, I need to know when the launching of an application is completed, i.e. when exactly the application is drawn completely and visible to the user. ViewTreeObserver.OnGlobalLayoutListener() has single method - onGlobalLayout(). I see that it is called multiple times, but I cannot detect the r...
helleye
1

votes
2

answer
502

Views

How to change Android NavigationView's selected item in relation to fragment's popBackStack

I implemented the new NavigationView (from the support library) and a couple of Fragments, I then overrided the onBackPressed function and added this: getFragmentManager().popBackStack(); which returns me to the previous fragment. So what I need is this: how I can change the navigationview's current...
pariola
1

votes
3

answer
1.2k

Views

how to remove empty list item in recycler views?

I'm using recycler view to show items with multiple views. whenever I launch the app some white space is being showed. which is exactly equal to my list items. I provided the screenshot please go through it. I think there is no problem with my code. following is my code recyclerview adapter code imp...
hemanth5636
1

votes
3

answer
487

Views

how to align to right and middle in height in layout

I have a Switch, witch is aligned to the left of a layout, I want to align a TextView to the right of it AND to the middle of the height of it. I have done two example pictures to explain it more clearly. This is what i have (where A is the Switch, and b is the TextView): This is what i want to ac...
Chief Madog
0

votes
1

answer
19

Views

onClickListener not working on tabbed layout on cardview

Hello guys hope y'all doing good. I have a problem here. I have activity with cardview inside tabbed layout. When use onclicklistener inside tabbed layout it is not working. But when use it without tabbed layout it works. How can i use it inside tabbed layout. cardview-activity: public class zurhai_...
1

votes
1

answer
1.4k

Views

How does pivotX/Y work in a rotate animation set

I am trying to understand how rotate animation works. With the following I rotate a view as follows: Result: Now where the arrow is I am trying to rotate again using that as a center. So I modified my animation set as follows: I.e. I added This seems correct to me because looking at the scree...
Jim
1

votes
3

answer
385

Views

Layout with two fragments: one fragment and a fragment with the Google Map

I'm trying to implement the following design. TextView should take up space by content, and the rest of the space is a map. +----------------+ | | | Map |
tim4dev
1

votes
2

answer
110

Views

TextView is not fit in ScrollView

I have a problem that TextView doesn't match with ScrollView ... Here is my code: s.th that shows and is false (better to say in this way that about 5 first line is hidden)
1

votes
1

answer
159

Views

View extending EditText loses Styles and is not focusable

I try to subclass EditText for convenience reasons (NumberEdit) using kotlin but the rendered View loses most of the EditText properties. The look is that of a TextView and it is not focusable with the mouse (in the emulator). When I click into the activity I can then edit the first of the NumberEdi...
Candlejack
1

votes
2

answer
934

Views

Set container layout above BottomNavigationView

I have this layout. This layout contains BottomNavigationView and container for nested fragments How can I set app_bar_main above BottomNavigationView top? because now: BottomNavigationView cross with
ip696
0

votes
0

answer
17

Views

Load library and main activity from a app [on hold]

I have seen several app in google play as "parallel space, dual apps" and etc ... but I wanted to create my own launcher for a game, and I know it is necessary to load the game library and main activity, but I have to Minimal idea how to do this, I ask for help on how to load the main activity and t...
Noob Zando
1

votes
1

answer
254

Views

Fragment inflation from different flavors

I am learning Android and I cannot find the solution to a fragment instantiation error when they are in different flavors. Setup: I have a main fragment that is loaded into the main activity. I have two favors: paid and free. The main (common) part of the app doesn't have the fragment (layout + java...
Judit Juhasz
1

votes
1

answer
242

Views

How to set color in odd and even position in recyclerview?

Position break in recyclerview (https://drive.google.com/file/d/1EZADHjrpn8ZwryvQ6qPf1xU1hcG0-Mgf/view?usp=drivesdk)
Shrey Dhingani
1

votes
1

answer
328

Views

BottomNavigationView taking space after click

I am using BottomNavigationView in my code to show 5 icons. When I click on the icon a new fragment is opened. I have 2 problems with the BottomNavigationView implementation The buttons are white but they appear gray in the BottomNavigationView. How can I make it look white. I also have set the icon...
Psypher
0

votes
0

answer
12

Views

Q: Android - Custom UI Dialog Questions (and BestPractice for my case)?

I am trying to determine the best route of attack for displaying my Dialog.. So many options - between Dialog Activities, AlertDialog's, DialogFragment's, etc.. I'm left unsure of which to utilize, and could use some advice. From what I understand, DialogFragment's are recommended as Best Practice....
Studio2bDesigns
1

votes
2

answer
188

Views

Android Google Map - Map Type selection from FAB menu

I'm trying to create a nice looking menu to change the map type, exactly like what is on Google Maps.. It appears when you click the layers FAB. I don't know if it's a custom FAB menu, or if it animates and opens a fragment. How to achieve this look?
NicCoe
1

votes
5

answer
169

Views

Why are the XML Elements not visible on my emulator in android studio?

My problem is that the controls (checkboxes, buttons etc) which I have placed are not visible on my emulator. Below is my XML file: Here is my XML (design view): Here is my emulator window: Is there is something wrong in my XML file? Please provide me solution for this. How should I handle this?
PEEHU GANDHI
1

votes
2

answer
425

Views

How to wrap_content or “fill available space” in ConstraintLayout

I have this layout: ... This recyclerview is added to the "id/content" framelayout It has the desirable effect that the recyclerview is placed at the bottom of the screen. The problem arises when there are many viewholders in the recyclerview. I would like to leave some room at the top to still see...
Chris Woolfe
1

votes
3

answer
177

Views

Create a RecyclerView with multiple view from layouts

I am trying to have 2 layout in one RecyclerView I have a recycler view list which is called Bookmark and it is parsed from an xml and this is all working , but I wanna in this recyclerview to put another layout which contains a button and that can be clickable. Like in the photo the icons are from...
Spritzig
1

votes
2

answer
116

Views

Imageview with rounded corner using kotlin [duplicate]

This question already has an answer here: How to make an ImageView with rounded corners? 40 answers I have created the layout with Imageview and I have set custom background with corner radius, the parent layout is cornered but the Imageview is not rounded cornered. How can I achieve this? Thanks i...
VigneshK
1

votes
3

answer
52

Views

Spacing views equally in a ConstraintLayout

I'm trying to make 5 ImageButton on ConstraintLayout with Equal spacing between them, but i get some problem to anchor them and make it easily for example: My xml code: android:id="@+id/navigation" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="botto...
DolDurma
1

votes
1

answer
100

Views

How to show a custom view above Action Bar in Android

Screenshot from google music app: I have these two questions: 1. How element like this is called and how can I implement something like this? 2. How they can it be above the action bar?
Paweł Kiełb
1

votes
4

answer
42

Views

Wrong TextView position in LinearLayout

I have two TextView in LinearLayout: It looks like this: If I remove android:gravity="center" it looks fine. But I need to use it. How to fix it?
shmakova
1

votes
4

answer
72

Views

Relative layout with wrap content

I want to customize AlertDialog to have a fixed header and a footer with scrollable RecyclerView. So I tried to do it with RelativeLayout but if there are many items in RecyclerView then the footer hides below RecyclerView. And I add fixed height to the RecyclerView then if there are fewer items the...
Arti
2

votes
3

answer
291

Views

clicking on TextInputLayout crashes in Oppo F1S running 5.1.1

After clicking on TextInputLayout, the app crashes after a delay of 1 sec in Oppo F1S running 5.1.1. I dont have access to device fist I got crash reported by crashlytics, then I asked my remote friends to try it on their oppo phone. I am not able to figure out the cause, and again as I dont have ac...
Ritzor
0

votes
0

answer
4

Views

Change vertical bias when there's not enough space

Problem I have a TextView inside a ConstraintLayout. Consider the TextView is 20dp high, and I want it to be at the top of the ConstraintLayout with a margin of 50dp. However, the ConstraintLayout's height is not fixed, and it is possible to be less than 70dp, meaning the TextView may not fit in the...
Milack27

View additional questions