Nested linear layout buttons texts cropped off at the end - android

Android Studio 0.4.5
Hello,
I have created a dialog box from an Activity. Which displays like this:
The cancel has a missing 'l' and the delete has a missing 'e'.
I have tried to adjust the text size, but that didn't work. I have been playing around with it. But can't seem to find a solution.
Here my xml layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/ivRabbitLogo"
android:layout_width="match_parent"
android:layout_height="64dp"
android:scaleType="center"
android:background="#ff20a3ff"
android:contentDescription="Logo of Application" />
<EditText
android:id="#+id/etUpdateDlgName"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inputType="text"
android:hint="Name"
android:textSize="22sp" />
<EditText
android:id="#+id/etUpdateDlgPhone"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inputType="phone"
android:hint="Phone"
android:textSize="22sp" />
<EditText
android:id="#+id/etUpdateDlgEmail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inputType="textEmailAddress"
android:hint="Email"
android:textSize="22sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:layout_weight="1">
<Button
android:id="#+id/btnCancel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Cancel"
android:textSize="20sp"
android:layout_weight="1" />
<Button
android:id="#+id/btnSave"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Save"
android:textSize="20sp"
android:layout_weight="1" />
<Button
android:id="#+id/btnDelete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Delete"
android:textSize="20sp"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
Many thanks for any suggestions,

Have a look at this
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="#+id/ivRabbitLogo"
android:layout_width="match_parent"
android:layout_height="64dp"
android:background="#ff20a3ff"
android:contentDescription="Logo of Application"
android:scaleType="center" />
<EditText
android:id="#+id/etUpdateDlgName"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="Name"
android:inputType="text"
android:textSize="22sp" />
<EditText
android:id="#+id/etUpdateDlgPhone"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="Phone"
android:inputType="phone"
android:textSize="22sp" />
<EditText
android:id="#+id/etUpdateDlgEmail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="Email"
android:inputType="textEmailAddress"
android:textSize="22sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="#+id/btnCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Cancel"
android:textSize="20sp" />
<Button
android:id="#+id/btnSave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Save"
android:textSize="20sp" />
<Button
android:id="#+id/btnDelete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Delete"
android:textSize="20sp" />
</LinearLayout>

you should not use android:layout_weight="1" in BUtton(childs), use android:weight="1" instead.

Use this...
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="#+id/ivRabbitLogo"
android:layout_width="match_parent"
android:layout_height="64dp"
android:background="#ff20a3ff"
android:contentDescription="Logo of Application"
android:scaleType="center" />
<EditText
android:id="#+id/etUpdateDlgName"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="Name"
android:inputType="text"
android:textSize="22sp" />
<EditText
android:id="#+id/etUpdateDlgPhone"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="Phone"
android:inputType="phone"
android:textSize="22sp" />
<EditText
android:id="#+id/etUpdateDlgEmail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="Email"
android:inputType="textEmailAddress"
android:textSize="22sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal" >
<Button
android:id="#+id/btnCancel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Cancel"
android:textSize="20sp" />
<Button
android:id="#+id/btnSave"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Save"
android:textSize="20sp" />
<Button
android:id="#+id/btnDelete"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Delete"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>

Declare you button with following change,
Just add a weight tag with Button like below,
<Button
android:id="#+id/btnCancel"
android:layout_width="0dp" // Change here
android:layout_height="wrap_content"
android:text="Cancel"
android:textSize="20sp"
android:layout_weight="1" />
<Button
android:id="#+id/btnSave"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Save"
android:textSize="20sp"
android:layout_weight="1" />
<Button
android:id="#+id/btnDelete"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Delete"
android:textSize="20sp"
android:layout_weight="1" />

try this in your code...hopefully this will work..
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:orientation="horizontal"
android:layout_weight="1">
<Button
android:id="#+id/btnCancel"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="Cancel"
android:textSize="20sp"
android:layout_weight="1" />
<Button
android:id="#+id/btnSave"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="Save"
android:textSize="20sp"
android:layout_weight="1" />
<Button
android:id="#+id/btnDelete"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="Delete"
android:textSize="20sp"
android:layout_weight="1" />
</LinearLayout>

Related

How to make a numpad similar layout in android

How do i make the numpad layout as shown in the uploaded picture.
This is my current code which would not show anything in the design view. I used this code previously on other views which work but this time it does not work and none of the buttons were visible at all in the design view.And also how do i make the 0 button as it is in the picture. This is my 2nd time asking questions in stackoverflow so do let me know if my questions are not clear and also english is not my first language. Thank you in advanced!
Edit: I have to make this layout through xml coding and not the usual thing
where the users click on the textview and the numpad of the phone
shows up. I hope this clarify the doubts of my question. I have to
make the clear, cancel and exit button as well.
<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:orientation="vertical"
android:weightSum="4"
android:layout_weight="4"
android:background="#drawable/background"
tools:context=".insert_amount">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="250dp">
<VideoView
android:id="#+id/videoview1"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
<TextView
android:id="#+id/textview1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Player"
android:textSize="30dp"
android:layout_marginTop="10dp"
android:layout_gravity="center_horizontal"
android:textColor="#color/white"
/>
<TextView
android:id="#+id/textview2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Display ID"
android:textSize="30dp"
android:textStyle="bold"
android:layout_marginTop="20dp"
android:layout_gravity="center_horizontal"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/content_box"
android:layout_marginTop="10dp"
android:layout_marginStart="50dp"
android:layout_marginEnd="50dp"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/in"
android:layout_gravity="center_horizontal"
android:layout_marginTop="50dp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Top Up Amount (IN)"
android:textSize="30dp"
android:layout_marginTop="10dp"
android:gravity="center_horizontal"
/>
<TextView
android:id="#+id/textviewnumber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="0.00"
android:textSize="40dp"
android:textStyle="bold"
android:gravity="center"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:weightSum="4"
android:orientation="horizontal">
<Button
android:id="#+id/button1"
android:layout_width="0dp"
android:layout_weight="1"
android:background="#drawable/login_signoutbutton"
android:layout_height="fill_parent"
android:text="1"
/>
<Button
android:id="#+id/button2"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="fill_parent"
android:background="#drawable/login_signoutbutton"
android:text="2"
/>'
<Button
android:id="#+id/button3"
android:layout_width="0dp"
android:layout_weight="1"
android:background="#drawable/login_signoutbutton"
android:layout_height="fill_parent"
android:text="3"
/>
<ImageButton
android:id="#+id/buttonclear"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="fill_parent"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:scaleType="fitCenter"
android:background="#drawable/login_signoutbutton"
android:src="#drawable/clear_button"
android:layout_margin="20dp"
/>
Try this
<?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">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Player"
android:textColor="#FFFFFF" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="12345679"
android:textColor="#FFFFFF" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:src="#drawable/kid_goku" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:text="Top up Amount" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:hint="Top up Amount" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:layout_marginHorizontal="2dp"
android:layout_weight="1"
android:text="1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:layout_marginHorizontal="2dp"
android:layout_weight="1"
android:text="4" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="2dp"
android:layout_weight="1"
android:text="7" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:layout_marginHorizontal="2dp"
android:layout_weight="1"
android:text="2" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:layout_marginHorizontal="2dp"
android:layout_weight="1"
android:text="5" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:layout_marginHorizontal="2dp"
android:layout_weight="1"
android:text="8" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="2dp"
android:layout_weight="1"
android:text="0" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:layout_marginHorizontal="2dp"
android:layout_weight="1"
android:text="3" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:layout_marginHorizontal="2dp"
android:layout_weight="1"
android:text="6" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:layout_marginHorizontal="2dp"
android:layout_weight="1"
android:text="9" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:orientation="vertical">
<Button
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginHorizontal="2dp"
android:layout_marginTop="8dp"
android:layout_weight="1"
android:background="#9b5006"
android:drawableLeft="#drawable/ic_camera"
android:text="Clear"
android:textColor="#FFFFFF"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_marginHorizontal="2dp"
android:layout_marginTop="15dp"
android:layout_weight="1"
android:background="#9b5006"
android:drawableLeft="#drawable/ic_camera"
android:text="Cancel"
android:textColor="#FFFFFF"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_marginHorizontal="2dp"
android:layout_marginTop="12dp"
android:layout_weight="1"
android:background="#9b5006"
android:drawableLeft="#drawable/ic_camera"
android:text="Next"
android:textColor="#FFFFFF" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
OUTPUT
Your layout height exceeding the device display. You have to use ScrollView here. Also for making the number keypad using GridLayout link will be better choice and you can easily get '0' button position using this view.

Not able to scroll my Linear Layout using ScrollView?

This is my XML file for presenting the Layout.
edit_screen.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/login_bg">
<LinearLayout
android:id="#+id/ll_userregisteration"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginTop="30dp"
android:isScrollContainer="true"
android:gravity="center"
android:orientation="vertical">
<RelativeLayout
android:layout_width="110dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp">
<com.shout.networking.view.RoundedImageView
android:id="#+id/profile_image"
android:layout_width="100dp"
android:layout_height="100dp"
android:scaleType="center"
android:src="#drawable/profile_placeholder"/>
<ImageButton
android:id="#+id/camera"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="What do we call you"
android:textColor="#color/white"
android:textSize="18sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="#+id/et_reg_Fname"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
android:textSize="16sp"
android:layout_weight="1"
android:backgroundTint="#color/white"
android:hint="first name"
android:textColor="#color/white"
android:textColorHint="#7c7875" />
<EditText
android:id="#+id/et_reg_Lname"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_weight="1"
android:textSize="16sp"
android:backgroundTint="#color/white"
android:hint="last name"
android:textColor="#color/white"
android:textColorHint="#7c7875" />
</LinearLayout>
<RadioGroup
android:id="#+id/radioGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<RadioButton
android:id="#+id/rb_male"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="#null"
android:checked="true"
android:drawableLeft="#drawable/selector_radio_button"
android:drawablePadding="10dp"
android:text="Male"
android:textColor="#android:color/white"
android:textSize="18sp" />
<RadioButton
android:id="#+id/rb_female"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="#null"
android:checked="false"
android:drawableLeft="#drawable/selector_radio_button"
android:drawablePadding="10dp"
android:text="Female"
android:textColor="#android:color/white"
android:textSize="18sp" />
</RadioGroup>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="School of your cool"
android:textColor="#color/white"
android:textSize="18sp" />
<EditText
android:id="#+id/et_university"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/white"
android:textSize="14sp"
android:hint="add your university"
android:textColor="#color/white"
android:textColorHint="#7c7875" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="what you call home"
android:textColor="#color/white"
android:textSize="18sp" />
<EditText
android:id="#+id/et_livingaddress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/white"
android:hint="Where do you live now"
android:textColor="#color/white"
android:textSize="16sp"
android:textColorHint="#7c7875" />
<EditText
android:id="#+id/et_permanentaddress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/white"
android:hint="Where do you belong to"
android:textSize="16sp"
android:textColor="#color/white"
android:textColorHint="#7c7875" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Whats Your Calling"
android:textColor="#color/white"
android:textSize="18sp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/et_interset"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/white"
android:layout_toLeftOf="#+id/sp_interset"
android:hint="Type in your calling/pick from the list"
android:textSize="16sp"
android:maxLength="30"
android:textColor="#color/white"
android:textColorHint="#7c7875"
android:maxLines="1" />
<Spinner
android:id="#+id/sp_interset"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:layout_centerVertical="true"
android:background="#drawable/down_thicker"
android:dropDownWidth="250dp"
android:backgroundTint="#android:color/white"
android:popupBackground="#4b4b49"
android:spinnerMode="dropdown" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="2"
android:layout_marginTop="10dp">
<Button
android:id="#+id/btn_cancel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#drawable/selector_signup_button"
android:text="CANCEL"
android:layout_marginRight="20dp"
android:textColor="#color/black"
android:layout_weight="1"
android:textSize="15sp" />
<Button
android:id="#+id/btn_save"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#drawable/selector_signup_button"
android:text="SAVE"
android:textColor="#color/black"
android:layout_weight="1"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>
</ScrollView>
This is the screenshot for my Layout.I am not able to scroll it.
I have put my Linear LAyout in the ScrollView but then also i am unable to get the scroll functionality in my xml design .
make changes in LinearLayout height to match_parent. it will work.
In ScrollView try adding this line:
app:layout_behavior="#string/appbar_scrolling_view_behavior"

Make the control in LinearLayout not to fill all the space

I have a layout like this:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="fsfsdfds"
android:layout_gravity="center_vertical" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="fdsfdsfds"
android:layout_gravity="center_vertical" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" />
</LinearLayout>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content" />
It fill the whole space of the activity.
How can I make these 2 TextViews and EditTexts take only space enough to show themselves (not fill all the space) and align the button to the bottom?
I think this is what you're looking for :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="TextView1" />
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:inputType="text" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/LinearLayout1"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="TextView2" />
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:inputType="text" />
</LinearLayout>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Button" />
</RelativeLayout>
EDIT :
If you don't want to use the two LinerLayouts (and therefore gain even more performance), you can do the following :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/TextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/EditText1"
android:layout_gravity="center_vertical"
android:text="TextView1" />
<EditText
android:id="#+id/EditText1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_gravity="center_vertical"
android:layout_toEndOf="#id/TextView1"
android:layout_toRightOf="#id/TextView1"
android:inputType="text" />
<TextView
android:id="#+id/TextView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/EditText2"
android:layout_below="#id/TextView1"
android:layout_gravity="center_vertical"
android:text="TextView2" />
<EditText
android:id="#+id/EditText2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="#id/EditText1"
android:layout_gravity="center_vertical"
android:layout_toEndOf="#id/TextView2"
android:layout_toRightOf="#id/TextView2"
android:inputType="text" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Button" />
</RelativeLayout>
Check This.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="0.5"
android:text="fsfsdfds" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="0.5" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="0.5"
android:text="fdsfdsfds" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="0.5" />
</LinearLayout>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content" />
You try with RelativeLayout, or else if wanted to be done with LinearLayout you need to consider weights if width is not fillparent.
Check below sample to start with ..
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="0.2"
android:text="fsfsdfds" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="0.8" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="0.2"
android:text="fdsfdsfds" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="0.8" />
Either convert to a relative-layout and use alignparentbottom for the button - or use layout weights for the linear-layouts

ScrollView Still comes Behind out of it's Area

This Is My 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="com.xxx.xxx.MyActivity" >
<LinearLayout
android:id="#+id/viewFromDateToDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:gravity="center"
android:orientation="horizontal" >
<EditText
android:id="#+id/txtFromDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableRight="#drawable/timesheet_icon"
android:editable="false"
android:focusableInTouchMode="false"
android:hint="#string/txtFromDate"
android:inputType="date"
android:onClick="selectDate"
android:textSize="#dimen/generalTextSize" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:text="#string/lblFromTo"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="#dimen/generalTextSize" />
<EditText
android:id="#+id/txtToDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableRight="#drawable/timesheet_icon"
android:editable="false"
android:focusableInTouchMode="false"
android:hint="#string/txtToDate"
android:inputType="date"
android:onClick="selectDate"
android:textSize="#dimen/generalTextSize" />
<Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:background="#drawable/green_button_department"
android:text="#string/btnShowData"
android:textColor="#color/white" />
</LinearLayout>
<View
android:id="#+id/upperSeparator"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_below="#id/viewFromDateToDate"
android:layout_marginTop="15dp"
android:background="#android:color/darker_gray" />
<LinearLayout
android:id="#+id/viewTimeOffDetailsHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/upperSeparator"
android:orientation="horizontal"
android:padding="10dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="#string/txtHeaderTimeOff"
android:textSize="#dimen/generalTextSize" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="#string/txtHeaderDate"
android:textSize="#dimen/generalTextSize" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/txtHeaderHours"
android:textSize="#dimen/generalTextSize" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/txtHeaderAction"
android:textSize="#dimen/generalTextSize" />
</LinearLayout>
<View
android:id="#+id/lowerSeparator"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_below="#id/viewTimeOffDetailsHeader"
android:background="#android:color/darker_gray" />
<ScrollView
android:id="#+id/scrollDiv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/lowerSeparator" >
<LinearLayout
android:id="#+id/viewTimeOffDetailsArea"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/viewTimeOffDetailsFooter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="15dp"
android:background="#drawable/green_button_department"
android:text="#string/btnSubmitTimeOff"
android:textColor="#color/white"
android:textSize="20sp" />
</LinearLayout>
</RelativeLayout>
I want my LinerLayout scrollDiv to Be in Between of lowerSeparator and viewTimeOffDetailsFooter But the problem is ScrolView is still displaying it's Elements After viewTimeOffDetailsFooter Starts.
.
Here is an output.
Of XML Layout
Here you can see the Buttons of scrollDiv Still Displays after viewTimeOffDetailsFooter Buttons. I know that i should not put whole File But i am not getting proper solution that's why. Thanks.
you just need to place it above the viewTimeOffDetailsFooter, by adding below attribute to your scrollDiv
android:layout_above="#+id/viewTimeOffDetailsFooter"
Your viewTimeOffDetailsFooter doesn't have any positional link with scrollDiv, so add to it new rule android:layout_below="#id/scrollDiv". It can work only without android:layout_alignParentBottom="true" rule - need to try.

QuickcontactBadge not showing up in Layout when ran the app

I am using a FrameLayout with some EditText controls and a QuickContactBadge. Its fine till here. when I run the app, I am able to see all the controls, but QuickContactBadge not appearing in the layout.
What I need to do to make it visible? Did I miss anything?
This is my layout file,
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY"
android:src="#drawable/pattern1" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="50dp"
android:orientation="vertical" >
<ScrollView
android:layout_width="wrap_content"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<QuickContactBadge
android:id="#+id/quickContactBadge1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="10dp"
android:scaleType="centerCrop" />
<EditText
android:id="#+id/txtlastname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/edttxtfirstname"
android:layout_marginTop="50dp"
android:ems="10"
android:hint="Last Name"
android:inputType="textPersonName"
android:textColor="#000000" />
<EditText
android:id="#+id/edttxtfirstname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:ems="10"
android:hint="First Name"
android:inputType="textPersonName"
android:textColor="#000000" >
<requestFocus />
</EditText>
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#000000" >
</View>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<TextView
android:id="#+id/txtheadingphone"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignRight="#+id/editText2"
android:layout_gravity="center"
android:layout_marginRight="70dp"
android:layout_weight="0.63"
android:gravity="center_vertical"
android:text="Phone"
android:textColor="#ffffffff" />
<ImageButton
android:id="#+id/imgbtnaddphone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/ic_input_add" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<Button
android:id="#+id/btnchphone"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Phone"
android:textColor="#ffffffff" />
<EditText
android:id="#+id/edttxtphone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.48"
android:ems="10"
android:gravity="center"
android:hint="Phone Number"
android:inputType="phone"
android:textColor="#000000" />
<ImageButton
android:id="#+id/imgbtndelphone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/ic_input_delete" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#000000" >
</View>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<TextView
android:id="#+id/txtheadingaddress"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignRight="#+id/editText2"
android:layout_gravity="center"
android:layout_marginRight="70dp"
android:layout_weight="0.63"
android:gravity="center_vertical"
android:text="Address"
android:textColor="#ffffffff" />
<ImageButton
android:id="#+id/imgbtnaddAddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/ic_input_add" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<Button
android:id="#+id/btnAddress"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Home"
android:textColor="#ffffffff" />
<EditText
android:id="#+id/edttxtaddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:gravity="center"
android:hint="Address"
android:inputType="textPostalAddress"
android:textColor="#000000" />
<ImageButton
android:id="#+id/imgbtndeladdress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/ic_input_delete" />
</LinearLayout>
<EditText
android:id="#+id/edttxtcity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:gravity="center"
android:hint="City"
android:textColor="#000000" />
<EditText
android:id="#+id/edttxtstate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:gravity="center"
android:hint="State"
android:textColor="#000000" />
<EditText
android:id="#+id/edttxzipcode"
android:layout_width="236dp"
android:layout_height="wrap_content"
android:ems="10"
android:gravity="center"
android:hint="ZipCode"
android:inputType="phone"
android:textColor="#000000" />
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#000000" >
</View>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<TextView
android:id="#+id/txtemail"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginRight="70dp"
android:layout_weight="0.63"
android:gravity="center_vertical"
android:text="Email"
android:textColor="#ffffffff" />
<ImageButton
android:id="#+id/imgbtnaddemail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/ic_input_add" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<Button
android:id="#+id/btnchemail"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Email"
android:textColor="#ffffffff" />
<EditText
android:id="#+id/edttxtemail"
android:layout_width="128dp"
android:layout_height="wrap_content"
android:layout_weight="0.48"
android:ems="10"
android:gravity="center"
android:hint=""
android:inputType="textEmailAddress"
android:textColor="#000000" />
<ImageButton
android:id="#+id/imgbtndelemail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/ic_input_delete" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:id="#+id/LinearLayout02"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:background="#AA000000" >
<Button
android:id="#+id/btnsave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="addCustomerDetails"
android:text="Save"
android:textColor="#000000"
>
</Button>
<Button
android:id="#+id/btncancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Cancel"
android:textColor="#000000"
android:onClick="canceladdcustomer">
</Button>
</LinearLayout>
</FrameLayout>
Please correct me or provide any useful links, so that I will come to know my mistake.
Thanks for your valuable help!!

Categories

Resources