FAQ Database Discussion Community


Different buttons size

android,android-layout,button,android-linearlayout
I'm quite new to Android, and I'm getting different sizes when I deploy my app to my smarthphone. Here goes the screenshots: Android Studio Preview: Smartphone screenshot: Please note the "/" button is smaller than anothers. Here goes the problem: android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" This padding is truncating my last button, but...

LinearLayout two TextViews Side by Side not taking equal width

android,xml,android-linearlayout
I have two side by side TextViews in LinearLayout, but second TextView taking more space than first one and i want both to take equal width that's why i have used layout_weight="1" but did not solve my issue, check below: <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_margin="20dp" android:gravity="center"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:drawableLeft="@drawable/as_individual"...

How to get ListView underneath buttons

android,textview,alignment,android-linearlayout
Right now my listview is to the right of my last button, but I want it to be underneath all three of my buttons (which are all on the same row). How can I get my listview underneath my buttons? Here is my code <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center_horizontal|bottom"...

How to pass additional arguments to a Constructor when extending a LinearLayout in Android?

android,class,constructor,android-linearlayout,extend
I have the following question, if I have a class extending a LinearLayout like: public class ExtendedSeekbarLayout extends LinearLayout { ..} and I would like to pass additional Arguments to my Layout, how do I do this? I know that I could have the following constructors like: public ExtendedSeekbarLayout (Context...

Dynamically position elements in a horizontal linearlayout

android,android-layout,android-linearlayout
Using Android API 10. I have a scenario where I need to dynamically add views to a horizontal LinearLayout. The layout should support 0-3 views, between views there should be a 1px vertical divider. If no view is added a placeholder text should be added in the center of the...

How can I set Imageview and Textview on same line in LinearLayout

android,android-linearlayout
I want to set Imageview and Textview on same line in LinearLayout but the Imageview is always higher than the Textview. Here is my code: String b[] = cacBuocThucHien.split("#"); for (int j = 0; j < b.length; j++) { LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); LinearLayout.LayoutParams lp2 = new LinearLayout.LayoutParams(30,30);...

How To Use Same LinearLayout In Different Activities

android,android-activity,android-linearlayout
I want to use same LinearLayout in different activities. Selected LinearLayout's id in picture is previewLinear. What I want to do is, use previewLinear in a different activity. I have A and B activities. Firstly I do some changes for previewLinear in activity A (adding border, slice it to pieces...

Android ListView adding too many items

android,for-loop,android-listview,android-edittext,android-linearlayout
I am currently adding TextViews inside a LinearLayout inside a ListView element using a for loop, because the amount of TextViews I have to add in there is variable. I am adding the items to the ListViews like you normally do. The problem is, when I scroll the items start...

Table weight ignored when text length is long?

android-linearlayout
I have the following xml layout - if editText_model text is fairly short then the table is split 50/50 by the weight value. However the longer the text gets the more it squashes up the word Description. Why is it ignoring the 50/50 split? <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent"...

How to align horizontally 3 fix width buttons in LinearLayout? [on hold]

android,android-linearlayout
I have this layout: <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:paddingTop="32dp"> <Button android:layout_width="100dp" android:layout_height="wrap_content" android:text="Button1"/> <Button android:layout_width="100dp" android:layout_height="wrap_content" android:text="Button2"/> <Button android:layout_width="100dp" android:layout_height="wrap_content" android:text="Button3"/> </LinearLayout> I want to align...

Can't adjust weights in linear layout - android

android,xml,listview,layout,android-linearlayout
I've searched but couldn't figure out the problem. I want to make exactly like the above picture. I've used linear layout in vertical for the "Day Teams Score Status" And then for the content containing the values of above headings, I've used a listview. What I've achieved is that headings...

Q: SlidingDrawer is Not Scrolling Up

java,android,xml,android-linearlayout,slidingdrawer
My SlidingDrawer is working but not Scrolling Up enough. Handle when come to bottom of the "MENÜYE DÖN" button, stopping! I can't scroll more. I know SlidingDrawer is deprecated but I do not know the alternative. I can see in Preview, SlidingDrawer's border is narrow. Here is XML <?xml version="1.0"...

Adjusting layout of android activity to fit all screens and always display all information

java,android,xml,android-linearlayout,relativelayout
I have the above layout in my application, however I am using a Note 3 as the test device and whenever I make the design it's too big for most other phones. Here is my XML file. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:background="@drawable/backrepeat" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin"...

How to aligning textviews on the left and right side of a linearlayout

android,layout,android-linearlayout
According to below codes <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center_vertical|center_horizontal" android:layout_marginTop="15dip"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="نوع" android:gravity="left" android:layout_weight="1" android:id="@+id/txt_type" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="تاریخ:...

Adding a background image to RelativeLayout hide all others elements

android,background,android-edittext,android-linearlayout,android-relativelayout
I have a simple XML: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".LoginActivity" android:background="@drawable/login_background"> <LinearLayout android:orientation="vertical" android:layout_width="320dp" android:layout_height="160dp" android:layout_alignParentBottom="true" android:layout_marginStart="218dp"...

RelativeLayout is returning LinearLayout LayoutParams

android,android-linearlayout,android-relativelayout
Here is a snippet from my layout xml that defines my RelativeLayout. <RelativeLayout android:id="@+id/npvirrButtons" android:layout_width="match_parent" android:layout_height="0dp" > <Button android:id="@+id/buttonNPVLabel" android:layout_marginLeft="20dp" android:layout_alignParentLeft="true" android:layout_width="wrap_content" android:layout_height="match_parent" /> <Button android:id="@+id/buttonIRR_NFV" android:layout_marginLeft="20dp" android:layout_marginRight="20dp"...

Adding dynamically generated buttons next to each other in LinearLayout

java,android,android-linearlayout
I have tried finding examples of this problem, but can't find any that fits. What I want is two buttons next to each other, from automatically generated list of buttons. The method newAddButtonToLayout is my try to make something that would do that. I get this error when I run...

Linear layout with textview and button alignment

android,android-layout,android-linearlayout
I am trying hard time to align this paticular layout but unable to set it correctly. can anyone help me out with this. I need exactly the row layout as shown below: This is what I have now: <LinearLayout android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="1" android:orientation="horizontal" > <TextView android:id="@+id/txtTitle" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="10dip" android:layout_weight="1"...

Background EditText and ImageView are black?

android,android-layout,android-linearlayout
I'm creating a custom border to LinearLayout, to do it I'm using shape . The problem is when I set @drawable/custom_linear_border all EditText has background black. This problem occur with Android 2.3 because superior this problem does not occur. How could I solve it ? custom_linear_border <?xml version="1.0" encoding="utf-8"?> <shape...

Android : can't add view programmatically in linearLayout android

android,view,android-linearlayout,android-scrollview
i have fragment that has scrollview as a parent of layout and in scrollview i have a LinearLayout . when i'm trying to programmatically add view to that LinearLayout but i get the error " The specified child already has a parent. You must call removeView() on the child's parent...

LinearLayout Beneath LinearLayout full width?

android,xml,android-layout,android-linearlayout
I have an ImageView and a TextView that are the only items in my Android UI. Currently the TextView is in the same LinearLayout as the ImageView, so the text sometimes runs to 2 lines. I want to get the text on its own line, with the full width of...

Add images to linearlayout programmatically

android,imageview,scrollview,android-linearlayout,programmatically-created
I have a HorizontalScrollViewwith a LinearLayout in it and I want to add multiple images to layout programmatically with all of them in same height (about 300dp) and wrap content. something like they are fitted in the scroll area by scale. My problem is when the View is loaded there...

First time programmer confused as to why the EditText and Button fields aren't going where I want them to

android,xml,textview,android-linearlayout,relativelayout
I am coding in XML on android studios, and I am having trouble getting the EditText to be centered at the top and the Button to be centered in the center. I do not know a lot about code so the other things I've read about Relative vs Linear Layout...

Android ListView onScroll Fires Multiple Times

android,listview,scroll,android-linearlayout,onscroll
I have two views in my fragment. In the first view, I have a linear layout, which holds some controls and in the second view, I have a listview. I want the linear layout in the first view to be collapsed / expand when I scroll up / down listview....

Set Imageview Height And Width Programmitically

android,imageview,android-linearlayout,android-tablelayout
for (int i = 0; i < rows; i++) { TableRow row =new TableRow(this); View v = new ImageView(getBaseContext()); TextView tv_main =new TextView(this); ImageView iv = new imageView(this); tv_main.setText("Test"); iv.setImageDrawable(v.getResources().getDrawable(R.drawable.home_icon)); row.addView(iv); row.addView(tv_main); table_layout.addView(row); } How to set height and width programiticaly? I had tried iv.getLayoutParams().height=80; iv.getLayoutParams().width=100; but image is not...

Android how take full screen with more LinearLayout orientation horizontal

android,android-linearlayout
i'm trying to do a school day and i use multiple linearLayout with days and hours. With the layout_weight i can set the space for every elements inside the single LinearLayout. But my problem is how can i set the layout_weightfor the LinearLayout because they are set with orientation horizontal...

set items of LinearLayout at center screen programmatically

android,textview,android-linearlayout,relativelayout
I'm trying to create a grid type view where number of textView boxes will appear at the center of the screen(horizontally). I'm only testing for two rows now. This is my xml file: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin"...

update Views in layout when a view changes

android,android-layout,android-linearlayout,android-view
I have a LinearLayout with 2 views. when I move the upper view at runtime the second view doesn't move accordingly and I can't seem to find a solution. can anyone help? here's the layout I'm using right now: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin"...

How to Change from LinearLayoutManager to StaggeredGridLayoutManager in Fragment--Android

android,android-layout,android-fragments,android-linearlayout,android-gridlayout
I have StaggeredGridLayoutManager and LinearLayoutManager in RecyclerView in my Fragment. I am trying to change layout from grid to linear or from linear to grid when I choose mode from settings. If I choose grid, view will change from linear to StaggeredGridLayoutManager. If I choose linear view will change from...

How to vertical space filling?

android,xml,height,android-linearlayout
I am trying to make a calculator for Android, just for testing and start learn android... I was making the UI, the buttons of the calculator are configurated to get the width depending the size of the screen, but I don't know how to make that with the height. My...

How do I refactor android code to choose layout?

android,android-layout,refactoring,android-linearlayout
I have 1 top layout and 3 bottom layouts, a user drags items from top layout to one of the 3 below. The code below: puts sequentially every image in every bottom layout into a list removes items from each bottom layout puts them back into top layout public void...

Android. Fix the height of a fragment on all screens

android,fragment,android-linearlayout,relativelayout
I have this xml: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/infoinstalacion_fragment1_relative_imagen_poli" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/Pink"> <ImageView android:id="@+id/infoinstalacion_fragment1_imgfoto" android:layout_width="match_parent" android:layout_height="wrap_content" android:scaleType="fitXY" android:src="@drawable/pol_alza" />...

Percentange horizontal bar in android

android,android-linearlayout
I have two values difference of this I would like show colored horizontal bar in my layout. I have created: horizontal bar for 25 percent, for 50 percent, for 75 percent, for 100 percent. But when showing up in linearLayout everything shows the same as I am wrapping the image....

Facebook Sdk Has Not Been Initilized

android,android-activity,android-linearlayout,android-button,android-facebook
Hey I know this was asked before, but none of the solutions seem to help. I'm using first time Facebook SDK in my application. What I've tried: I had tried most of the things found on Internet but did not get anything regarding this. Here is my MainActivity.java: public class...

How to change top position of linearLayout in ReletiveLayout progammaticlly

android,android-layout,android-linearlayout
I want to change linearlayout that inside of ReletiveLayout. But when I use settop it doesn't work!!! and I can't find good tutorial <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ffffff" android:padding="5dp" > <LinearLayout android:id="@+id/remotebox" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:id="@+id/remote"...

How to set buttons on the same line for linear layout [duplicate]

android,button,alignment,android-linearlayout
This question already has an answer here: Right Align button in horizontal LinearLayout 9 answers I am trying to align my buttons so they are all aligned with each other side by side, but for some reason the next button shows up on the linear below. I must use...

Views in Linear Layout not getting equal space with android:layout_weight attribute

android,android-layout,android-linearlayout,android-layout-weight
As describe in the topic's title, I have 3 TextView and I would like them to share the whole screen's width using the android:layout_weight attribute, but doing so didn't get the sought results. LinearLayout: <TextView android:id="@+id/tour1" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="@drawable/back" android:clickable="true" android:gravity="center" android:paddingBottom="8dp" android:paddingLeft="10dp" android:paddingRight="10dp" android:paddingTop="8dp"...

How do i adjust ImageView if it falls outside of view Switcher bounds?

android,imageview,android-linearlayout,viewswitcher
i have view switcher(it contains 2 views of kettle - on and off) the first image is kettle "off" , and it stays outside of actual viewSwitcher. I tried fitXY, fixStart, fitCenter - did not help! Below is the layout of viewSwitcher I already tried to change the size...

set width and height as percentage in relative layout

java,android,android-linearlayout,android-layout-weight
I would like to have this: a ViewPager overlaid by 2 arrows And I get what I want by this code. However, I got these warnings of lint : this layout is useless (for dummy layouts) nested weights are bad for performance. I wonder if there is a better way...

Android ImageView margins

android,android-layout,android-linearlayout
Creating layout and can not solve margins up and above the ImageView (and don't understand why they appear). Logo itself is without these margins. I use layout_width="250dp" the same as for the buttons. And layout_height="wrap content". Layout code is here: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/menu_background" android:gravity="center"...

Linearlayout into cell of gridview

java,android,gridview,android-linearlayout
I have got a problem with programmatically created LinearLayout contains into design time created GridView. public class page2 extends Fragment { public View rootView; public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { rootView = inflater.inflate(R.layout.page2, container, false); String [] rings= { "1 пара", "8.30 - 10.05", "8.30 - 9.15...

Not able to add view dynamically

android,android-layout,android-linearlayout
I have linear layout R.id.linearLayoutQuantityPrice in XML. I want to add a new linear layout inside that dynamically. The new linear layout has two textviews and one imageview. List<Price> priceList = database.getItemQuantityPrice(id); LinearLayout linearLayoutQuantityPrice = (LinearLayout) rowView .findViewById(R.id.linearLayoutQuantityPrice); for (int i=0; i<priceList.size() ; i++) { Price price = new Price();...

How to create a layout which is rounded on all sides?

android-layout,android-linearlayout
I have created a layout which is supposed to have rounded corners on all the four sides. However, the layout shows rounded corners only in the left and right top corners. How to create a layout which has rounded corners on all the four sides (including the left and right...

Efficiently Inflating a lot of Views within several Horizontal LinearLayout with Adapters

android,performance,android-layout,android-linearlayout,android-adapter
I have a question about how to improve the performance of a large horizontal linear layout. I am creating a table like view that can have anywhere from 50 to 2,500 entries. Each entry is a LinearLayout containing a TextView with some simple text. I have implemented the design by...

Android: Right-Aligning ImageView in LinearLayout

android,android-layout,android-linearlayout,android-imageview
The imageView is not getting right-aligned in this linearlayout (If it matters this LinearLayout is actually a row in a list). But if i use a TextView (its commented in code below) instead of ImageView, it successfully gets right-aligned. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:background="#FFFFAA" android:orientation="horizontal" > <TextView android:id="@+id/txtTitle"...

Change layout background color on button click

android,android-linearlayout,background-color
I'm getting an error when trying to set the background color of a layout I get a nullpointerexception and I don't know why. I've looked at various posts (like this Change background color on button click?) and my code seems correct, but still the layout doesn't seem be called. This...

How to design this layout using Relative or Linear layout?

android,android-layout,android-linearlayout,android-relativelayout
Hi I am creating weather widget application. I have completed programming part. I am not familiar with layout design. please help me how to design this layout. Thanks in advance.

Handling an EditText that was added programatically

android,android-edittext,android-linearlayout,android-relativelayout
I've been making all of my views dynamically, and now I've come to the point where I want to add an EditText for people to write in. I've been able to accomplish this for the most part, but it doesn't look right. I have a linear layout that I'm adding...

Overlapping counter textview on image in relativelayout or linearlayout

android,android-linearlayout,relativelayout
I want to place a textview on top right corner of imageview and also to overlap some part of textview on to imageview. How can i do that. Right now I am doing this: <RelativeLayout android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_marginLeft="12dip" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imgMessage" android:src="@drawable/listing_message" /> <TextView android:id="@+id/tvMessageCounter" android:layout_width="20dip"...

Horizonal LinearLayouts in a Vertical LinearLayout

android,android-layout,android-edittext,android-linearlayout,android-button
I want a few EditTexts with buttons on their right. Right now I just have the Edittexts filling the parent with the 0dp trick. If I add the button the height of the EditText will shrink with wrap_content. If I do match_parent one EditText fills the entire screen. RelativeLayout doesn't...

Adding views programatically. displays nothing

android,android-linearlayout,android-button
I am adding a view to my table row programmatically. Everything is working fine and logcat isn't showing any errors. Strangely enough nothing is being displayed in my activity. Below is the code I am using: try{ int k=0; for(i=0;i<=Math.ceil(jArray.length()/2);i++){ Log.e("I...",""+i+" "+Math.ceil(jArray.length()/2)); tr_head = new TableRow(getApplicationContext()); tr_head.setId(10+i); tr_head.setPadding(30, 30, 30,...

Elements in layout cropped

java,android,android-layout,android-linearlayout
I have a problem with layout file, when i test it on devices with Android 4.1, why does it happens I don't know, so here's what i get: And here's the part of layout where it happens: <LinearLayout android:id="@+id/chooseType" android:layout_width="match_parent" android:layout_height="wrap_content" android:visibility="visible" android:layout_marginLeft="16dp" android:layout_marginStart="16dp" android:layout_marginRight="16dp" android:layout_marginEnd="16dp" android:layout_marginTop="12dp" android:orientation="horizontal"> <CheckBox...

TextView and Checkbox inside LinearLayout, but Checkbox disappears

android,checkbox,android-linearlayout
I have TextView and CheckBox inside LinearLayout. Checkbox must appear to the right of the TextView. In the Eclipse View, Checkbox appear, but when i launch app in my device checkbox disappears. This is Eclipse view (Checkbox is the star): This is part of my xml file: <RelativeLayout android:id="@+id/infoinstalacion_fragment1_relative_imagen_poli" android:layout_width="match_parent"...

Title bar like style for layout on android

android,android-linearlayout
I want to create a custom title bar like this using a linear layout. I can not work out how to get that 3D/shodow effect at the bottom. Any suggestions? <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item > <shape android:shape="rectangle"> <solid android:color="@android:color/darker_gray" /> <corners android:radius="0dp"/> </shape> </item> <item android:bottom="1dp" android:top="1dp"> <shape...

Android LinearLayout is not redisplayed after changing weights programmatically

android,android-linearlayout,weight,setcontentview
I am able to construct a LinearLayout of dozens of Views programmatically and to display it as the content view of an Activity. I am able to walk the LinearLayout tree and change the backgroundcolors of the Views. And I am able to walk the tree and adjust the relative...

Issue with UI in android

android,android-linearlayout,android-relativelayout
I am trying to achieve the following screen: Hence I tried the following code in XML: <RelativeLayout android:id="@+id/Numberlayout" android:layout_width="match_parent" android:layout_height="75dp" android:layout_marginLeft="5dp" android:visibility="visible" android:layout_marginRight="5dp" android:layout_marginTop="5dp" > <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:baselineAligned="false" android:orientation="horizontal" > <LinearLayout...

How to achieve equal layout_width and layout_height

android,xml,android-layout,android-linearlayout
What I am trying to achieve is to put 4 buttons next to each other, with some margins, and make them square (without supplying fixed sizes) I basically have a wrapper LinearLayout that holds 4 buttons, which I want them to be square shaped. <LinearLayout android:id="@+id/photos_photoWrapper" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:orienation="vertical">...

Delete top and bottom margins in dynamic Textviews Android

android,textview,android-linearlayout,center,gravity
How do I delete the top and bottom margins of the dots in the green LinearLayout? I have tried with setMargins to 0 but it not works This are my Java class and my XML's MainActivity.java public class MainActivity extends Activity { private ViewPager viewPager; private MyViewPagerAdapter myViewPagerAdapter; private ArrayList<Integer>...

Issue with Llinear layout hierarchy and alignment

java,android,alignment,android-linearlayout,center
I've some line of code in parent XML as below: <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <include android:id="@+id/header_parent_layout" layout="@layout/common_header_layout" /> <include android:id="@+id/title_header_layout" layout="@layout/title_header_layout" /> <LinearLayout android:id="@+id/content" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" />...

Adding layout to the bottom of screen in Android [closed]

android,android-layout,android-linearlayout,android-scrollview,android-layout-weight
I want to add a layout like this: <header layout>(Fixed) | | <ScrollView> | | <Footer Layout>(Fixed) Here's what I've tried so far: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <ScrollView android:id="@+id/container" android:layout_width="fill_parent" android:layout_height="fill_parent"...

Looking for some Android layout advice

android,android-linearlayout,relativelayout
I have an issue where I need to add several (>20) to a layout at run time and the buttons can be 2 different widths and 2 different heights. I dont know the exact size of these buttons at design time as the minimum size will be determined by the...

Align two pikers in LinearLayout

android,android-layout,android-linearlayout
I am doing Fragment with Pikers Elements. (and more elements but the problem is in Pikers elemets). I have two pikers (NumberPiker and TimePiker) in LinearLayout and i want to aling them. This is my xml code: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"...

Android, RelativeLayout in Adapter is causing ERROR

android,android-listview,android-linearlayout,relativelayout
I am trying to make a chat bubble, I have successfully did it with a text only, but when i want to add another text to put the time inside the bubble i had to add a RelativeLayout to put it on the actual linear layout, but this time i...

Android: Switch loses focus after click

forms,onclick,focus,android-linearlayout
Hey Hey currently I am developing an application that contains a form, with some edittext fields, some checkboxes and a switch at the end. The layout looks like this: <RelativeLayout> <ScrollView> <LinearLayout> <LinearLayout> <TextView></TextView> <Checkbox></Checkbox> </LinearLayout> <LineraLayout> <TextView></TextView> <EditText></EditText> </LinearLayout> <LinearLayout> <TextView></TextView> <Switch></Switch>...

Align TextViews to top of LinearLayout

android,android-layout,alignment,android-linearlayout,android-textview
I'm creating an app that has four different TextView inside a LinearLayout. The LinearLayout has a weight sum of 4 and every TextView has a weight of 1 (to make them with evenly width). My first problem is that two of the TextViews has a bigger height than the other...

Setting ImageViews side by side inside LinearLayout

android,android-linearlayout
I was trying to get two images side by side inside my LinearLayout. I tried setting my layout weight to 1 as suggested by many other posts I saw here for both views but to no avail. The imageViews in question are the ones with the ID rainfall and wind....

Align Android Relative Layout Items w/ Dynamic Size Item in Different Linear Layout

android,android-layout,android-linearlayout,android-relativelayout
I haven't been able to find anything out there on aligning a widget from a RelativeLayout to a widget within a horizontal LinearLayout. Aligning from one layout to another is almost not even mentioned on the Internet. I thought my question might be easiest explained with a picture. Please pardon...

Navigation drawer crashes when isDrawerOpen is called

android,android-linearlayout,navigation-drawer,gravity
I am trying to implement a navigation drawer in android studio. All of the examples I find seem to be using a ListView, I would prefer a linearLayout. The problem I am having is that when I call isDrawerOpen, my app crashes with "No drawer view found with gravity LEFT"....

Adapt layout to changing width of imageView

android,android-layout,android-linearlayout
I have a layout where one elements changes its size dynamically (the red imageView). The problem is that the Views below either disapear or don't align centered. The first two images show how it should look like: with LinearLayout below set to match_parent: with LinearLayout below set to wrap_content: This...

How to put this EditText on the right in a LinearLayout?

android,xml,layout,android-edittext,android-linearlayout
i created this form: writing this XML layout: <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <LinearLayout android:id="@+id/fields" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_marginTop="20dp" android:layout_marginLeft="20dp"...

Android force LinearLayout to resize views after view removal

android,android-linearlayout
I 've a LinearLayout with 2 views, view A which takes some vertical space, and view B which takes the rest of the layout. <LinearLayout android:id="@+id/ly2" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="@id/input" android:orientation="vertical" > <View android:id="@+id/view1" android:layout_width="match_parent" android:layout_height="50dp" > </View> <WebView android:id="@+id/webview" android:layout_width="match_parent" android:layout_height="match_parent" />...

Overlapping in RelativeLayout

android,android-layout,android-linearlayout,android-relativelayout
I have one RelativeLayout which contains 2 linearlayouts, one should always be aligned with bottom (for log out purpose.) and the other starts from top and contains 2 viewstubs. These two viewstubs have different heights any only one of them will be visible at same time. My problem is if...

Scolling with multiple RecyclerViews in Layout

android,scrollview,android-linearlayout,android-recyclerview
I have created a layout which has two RecyclerViews. One scrolls horizontally while other scrolls vertically. I can scroll correctly inside each RecyclerView but the page as a whole won't scroll i.e. top RecyclerView stays at top always and bottom one stays at bottom like both are fixed in position....

Android changing text on buttons programatically

android,button,android-linearlayout,dynamically-generated
I am making a grid of buttons 4 wide, 9 tall, all of the buttons are invisible and no text on them, I then programatically add text to them and make them visible (basically I am using the invisible buttons because any of the 36 buttons can become visible due...