I'm making a diary app. So I made a Linearlayout(I'll call this layout toolbox) of the tools needed to write like this image.
image
But I type text and edit text gets longer, toolbox overlap the bottom of an edit text. So can't see the text I'm typing.
I've done a lot of googling and I've used a way to add bottom margin to the layout, but it didn't work.
issue GIF here(Because it is hidden in the toolbox, can see the text I entered before, not the text I typing.)
There was this problem before I added a scroll view. I guess this problem isn't about scroll view.
How to prevent edit text from overlapping the view below?
Here's my XML
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".DiaryActivity">
<RelativeLayout
android:id="#+id/save_tap"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#android:color/white"
android:orientation="horizontal"
app:layout_constraintBottom_toTopOf="#+id/top_line"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
//elements
</RelativeLayout>
<View
android:id="#+id/top_line"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:background="#D1D1D1"
app:layout_constraintTop_toBottomOf="#+id/save_tap" />
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintTop_toBottomOf="#+id/top_line">
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:orientation="vertical"
app:layout_constraintBottom_toTopOf="#id/toolbox">
<EditText
android:id="#+id/edit_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|start"
android:layout_marginTop="20dp"
android:background="#null"
android:hint="#string/hint_diary_title"
android:textColor="#android:color/black"
android:textSize="23sp" />
<EditText
android:id="#+id/edit_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:background="#null"
android:ems="10"
android:gravity="start|top"
android:hint="#string/hint_diary_contents"
android:inputType="textMultiLine"
android:textColor="#515151" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/toolbox"
android:layout_width="match_parent"
android:layout_height="45dp"
android:background="#drawable/top_dividing_line"
android:gravity="center|left"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
//image buttons
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
try to add a linear layout which takes both your Scrollview and your toolbox layout.
Also can you show all of ur xml (including the parent layout?)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/save_tap"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#android:color/black"
android:orientation="horizontal">
</RelativeLayout>
<View
android:id="#+id/top_line"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:background="#D1D1D1"
app:layout_constraintTop_toBottomOf="#+id/save_tap" />
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#color/colorAccent"
android:fillViewport="true"
android:orientation="vertical"
app:layout_constraintTop_toBottomOf="#+id/top_line">
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:orientation="vertical"
app:layout_constraintBottom_toTopOf="#id/toolbox">
<EditText
android:id="#+id/edit_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|start"
android:layout_marginTop="20dp"
android:background="#null"
android:textColor="#android:color/black"
android:textSize="23sp" />
<EditText
android:id="#+id/edit_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:ems="10"
android:gravity="start|top"
android:inputType="textMultiLine"
android:textColor="#515151" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/toolbox"
android:layout_width="match_parent"
android:layout_height="45dp"
android:background="#android:color/holo_blue_bright"
android:gravity="center|left"
android:orientation="horizontal">
</LinearLayout>
</LinearLayout>
I added some colors to display the different layouts
Tell me if this is the behaviour you wants
Related
How do I create a layout with two buttons that can fill half of the layout from left and the second button on the right with also a view below as a border?
My layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorPrimary"
tools:context=".Login">
<RelativeLayout
android:gravity="center_horizontal"
android:layout_marginTop="70dp"
android:layout_marginBottom="70dp"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:background="#color/white"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="#dimen/_45sdp"
android:background="#color/white"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="#+id/btn_chat"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#color/white"
android:textColor="#color/colorPrimary"
android:textStyle="bold"
android:text="LOGIN" />
<Button
android:id="#+id/btn_cart"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#color/white"
android:textColor="#color/lightDark"
android:textStyle="bold"
android:text="REGISTER" />
</RelativeLayout>
<View
android:id="#+id/active_border"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:background="#color/colorPrimary"
android:layout_width="wrap_content"
android:layout_height="1dp"/>
<View
android:id="#+id/inactive_border"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:background="#color/lightDark"
android:layout_width="wrap_content"
android:layout_height="1dp"/>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
You could use the ConstraintLayout as the parent and set app:layout_constraintWidth_percent="0.5" in the child to make sure it takes the half of the width. Also use the constrain to make sure the buttons are on top of the border view.
For example the following code uses ConstraintLayout to achieve something similar:
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="#+id/btn1"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintBottom_toTopOf="#+id/borderView"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_percent="0.5" />
<Button
android:id="#+id/btn2"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="#+id/borderView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_percent="0.5" />
<View
android:id="#+id/borderView"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#android:color/black"
app:layout_constraintBottom_toBottomOf="parent" />
Hello i have added everything in my android manifest but the layout is cutting my xml when the keyboard is shown. what i expect is that nothing is cut off.
here is my xml...
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="1dp"
android:orientation="vertical"
tools:context=".Chat.MessageListFragmentLadoComercial">
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#color/colorPrimary"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/circle_image_chat_cliente"
android:layout_width="60dp"
android:layout_height="50dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="4dp" />
<TextView
android:id="#+id/nombre_cliente_chat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="15dp"
android:text="Nombre Cliente"
android:textColor="#android:color/white"
android:textSize="30sp"
android:textStyle="bold" />
</LinearLayout>
<androidx.core.widget.NestedScrollView
android:id="#+id/scroll_hasta_abajo"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_weight="9">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/reyclerview_message_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="10dp"
android:padding="22dp" />
</androidx.core.widget.NestedScrollView>
<!-- A horizontal line between the chatbox and RecyclerView -->
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/layout_chatbox"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="1dp"
android:layout_weight="1"
android:background="#ffffff"
android:minHeight="48dp"
android:orientation="horizontal">
<EditText
android:id="#+id/edittext_chatbox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_weight="1"
android:background="#android:color/transparent"
android:hint="Enter message"
android:isScrollContainer="true"
android:maxLines="6" />
<Button
android:id="#+id/button_chatbox_send"
android:layout_width="64dp"
android:layout_height="48dp"
android:layout_gravity="bottom"
android:layout_marginRight="30dp"
android:layout_marginBottom="0.5dp"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:gravity="center"
android:text="SEND"
android:textSize="14dp" />
</LinearLayout>
</ScrollView>
</LinearLayout>
and here is my manifest portion...
<activity
android:name=".Chat.MessageListActivityLadoComercial"
android:label="Chat"
android:windowSoftInputMode="adjustResize">
</activity>
Here is how it looks like....
So i want to do is that the horizontal linear layout is not cut off ive tried everything but it doesnt seem to work.
Use RelativeLayout instead of LinearLayout, in your case linearLayout2 because it can span over all the available space hence can get resized when the keyboard pops up. But LinearLayout don't get resized in the resizing process so your top linearlayout with circleimageview and title can't get resized.
Everything looks fine in my previews but when I open the app in an emulator the layout doesn't match parent for length or width. Everything is where it should be within the layout it just doesn't stretch overall with the screen. This is happening in every layout in the app(I'm using fragments). To explain better heres pix:
** What is in the preview(and is what i want)
** What I have
here is the XML.
<?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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="center"
android:src="#drawable/hlineand"/>
<TextView
android:id="#+id/userTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="User"
android:textAlignment="center"
android:textAppearance="#android:style/TextAppearance.Material.Small"
android:textColor="#android:color/darker_gray"
android:textSize="30dp"/>
<TextView
android:id="#+id/updateTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:text="----"
android:textAlignment="center"/>
<EditText
android:id="#+id/emailEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="22dp"
android:ems="10"
android:hint="e-mail"
android:inputType="textEmailAddress"
android:layout_below="#+id/userTextView"
android:layout_centerHorizontal="true"/>
<EditText
android:id="#+id/passwordEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/emailEditText"
android:layout_below="#+id/emailEditText"
android:layout_marginTop="24dp"
android:ems="10"
android:hint="password"
android:inputType="textPassword"/>
<Button
android:id="#+id/loginButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/passwordEditText"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:text="Login"/>
</RelativeLayout>
This is my content main.xml. Like the first commenter mentioned, it was in there. It worked great when I put in match parent & match parent but not its resizing to some like width 344px & height 590px. Any way I can keep that as match parent??
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.a2.reach.MainActivity"
tools:showIn="#layout/app_bar_main">
<FrameLayout
android:id="#+id/content_frame"
android:layout_width="344dp"
android:layout_height="495dp"
tools:layout_editor_absoluteY="8dp"
tools:layout_editor_absoluteX="8dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</android.support.constraint.ConstraintLayout>
Fixed the content main XML by changing the width height to 0dp instead of match parent & adding the 4 constraints on the bottom of the frame layout. Thank you guys and thank you as well to #Du.fantasy for pointing me in the right direction so fast
<FrameLayout
android:id="#+id/content_frame"
android:layout_width="0dp"
android:layout_height="0dp"
tools:layout_editor_absoluteY="8dp"
tools:layout_editor_absoluteX="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
change the FrameLayout to match_parent from fix width and height
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.a2.reach.MainActivity"
tools:showIn="#layout/app_bar_main">
<FrameLayout
android:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout_editor_absoluteY="8dp"
tools:layout_editor_absoluteX="8dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</android.support.constraint.ConstraintLayout>
As per my knowledge, In your first XML, Your are giving orientation="vertcial" to relative layout. If you want that it should work then you should use Linear layout and use orientation for that layout.
Try using like this in you content XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_blood_g_activity"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mature Diabetic Patient"
android:layout_gravity="center"
android:textSize="15dp"/>
<View
android:layout_width="wrap_content"
android:layout_height="30dp"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter Your current Blood Sugar"/>
<View
android:layout_width="20dp"
android:layout_height="60dp"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/cbs"
android:inputType="number"
android:hint="mg/dl"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter Your Target Blood Sugar"/>
<View
android:layout_width="20dp"
android:layout_height="60dp"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/tbs"
android:inputType="number"
android:hint="mg/dl"/>
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Humalog/Novalog"
android:id="#+id/btnhnbs"
android:layout_gravity="center"/>
</LinearLayout>
in my variant change size parent Layout - fixed my problem
<FrameLayout
android:id="#+id/map_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
</FrameLayout>
I made a layout for my app using linear layout. It looks fine and works fine but on rotation the layout changes very differently like the edit text becomes very small and disappears when keyboard appears. So how to provide a consistent look for my application. Or what am I missing?
Here is the code of the layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.nobodyme.errorrepository.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:background="#F5F5F5"
android:elevation="3dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginTop="16dp"
android:text="Folders"
android:textAppearance="?android:textAppearanceLarge"
android:textColor="#android:color/background_dark" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:gravity="center"
android:orientation="horizontal"
android:layout_marginBottom="16dp">
<EditText
android:id="#+id/foldername"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:layout_weight="4"
android:background="#android:color/background_light" />
<Button
android:id="#+id/enterFolderButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_weight="1"
android:text="OK"
android:textColor="#android:color/background_light"
android:background="#000000" />
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="5">
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/folderlistview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:cacheColorHint="#color/colorPrimary" />
<TextView
android:id="#+id/empty_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Create folders to add error"
android:textAppearance="?android:textAppearanceMedium" />
</RelativeLayout>
</LinearLayout>
Here how it looks on my device, four images below show how it looks on vertical and horizontal position with and without clicking on edit text, i.e with keyboard on and off.
When I rotate my screen to landscape mode, a DialogFragment containing this layout is cutting off the two buttons at the bottom:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="4dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Alias"/>
<EditText
android:id="#+id/edittext_alias"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textCapWords"
android:ems="10"
android:layout_marginLeft="4dp"
android:maxLength="30"
android:imeOptions="actionDone"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Interests"/>
<EditText
android:id="#+id/edittext_interests"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:ems="10"
android:layout_marginLeft="4dp"
android:maxLength="10"
android:imeOptions="actionDone"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bio"/>
<EditText
android:id="#+id/edittext_bio"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textCapSentences"
android:ems="10"
android:layout_marginLeft="4dp"
android:maxLines="2"
android:gravity="top"
android:imeOptions="actionDone"
android:requiresFadingEdge="vertical"
android:fadingEdgeLength="20dp"
android:scrollbars="vertical"
android:fadeScrollbars="false"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="#+id/button_cancel"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="Cancel"
android:layout_weight="1"/>
<Button
android:id="#+id/button_confirm"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="OK"
android:layout_gravity="center_horizontal"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
Am I doing something wrong or missing something obvious? How can I get it to force display everything?
I think the case is your screen is simply not large enough to show the whole content. Android does not add the scroll functionality if content is larger then the screen. If this is the case wrap all your views in a ScrollView so that the buttons could be visible after scrolling. Like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="4dp">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- Putt all your view here -->
</LinearLayout>
</ScrollView>
</LinearLayout>
Also you may put ScrollView as Your Parent View
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- Putt all your view here -->
</LinearLayout>
</ScrollView>